Single-phase reactive power determination method and device, storage medium and electronic equipment

CN122612992APending Publication Date: 2026-08-21HUAIROU LABORATORY SCIENCE & TECHNOLOGY ACHIEVEMENTS TRANSFORMATION CENTER HUAIROU DISTRICT BEIJING
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611080727.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-21
Publication Date
2026-08-21

AI Technical Summary

Technical Problem

受该机制约束,计算结果天然存在一个工频周期的输出时延,暂态扰动发生后无法同步输出实时无功数值,难以精准复现短路、负荷投切过程中瞬时无功波动变化,无法适配微步长电磁暂态仿真的实时观测需求

Benefits of technology

[0006]本申请仅采集相邻两个时刻的电压、电流瞬时值,无需缓存多周期波形数据。通过信号极性与过零特征直接求取相位差,配合实时计算的电压、电流有效值同步算出无功,从根源消除周期时延,实现电磁暂态仿真下无功功率实时测算。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122612992A_ABST
    Figure CN122612992A_ABST
Patent Text Reader

Abstract

The application discloses a single-phase reactive power determination method and device, a storage medium and an electronic device. The method comprises the following steps: obtaining the voltage instantaneous sampling value and the current instantaneous sampling value of a measured single-phase loop at a first sampling time and a second sampling time in an electromagnetic transient simulation model; determining the original phase difference angle between the voltage and the current of the measured single-phase loop according to the polarity relationship of the voltage instantaneous sampling value and the current instantaneous sampling value and the cross-time zero-crossing change characteristic; determining the voltage effective value of the measured single-phase loop based on the voltage instantaneous sampling value, and determining the current effective value of the measured single-phase loop based on the current instantaneous sampling value; and determining the single-phase reactive power of the measured single-phase loop according to the voltage effective value, the current effective value and the original phase difference angle. The application determines the phase by relying on the polarity of the voltage and the current instantaneous value and the cross-time zero-crossing characteristic, and calculates the effective value by combining the time sequence recursion filtering, so that the calculation power and the memory cost are low, and the transient reactive power fluctuation can be captured in real time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of power system technology, and in particular to a method, apparatus, storage medium and electronic equipment for determining single-phase reactive power. Background Technology

[0002] Current electromagnetic transient simulations commonly employ integer-cycle Fourier transform to calculate reactive power. This method requires continuously buffering voltage and current sampling data for at least one complete power frequency cycle, and then using complex frequency domain decomposition to extract the fundamental amplitude and phase before calculating reactive power. This approach, which uses a complete power frequency cycle as the sampling buffer interval, essentially uses a fixed-length data window for computation. Constrained by this mechanism, the calculation results naturally have an output delay of one power frequency cycle. After a transient disturbance occurs, it is impossible to synchronously output real-time reactive power values, making it difficult to accurately reproduce instantaneous reactive power fluctuations during short circuits and load switching, and thus unsuitable for the real-time observation requirements of micro-step electromagnetic transient simulations. Summary of the Invention

[0003] In view of the above problems, this application provides a method, apparatus, storage medium and electronic device for determining single-phase reactive power.

[0004] To solve the above-mentioned technical problems, this application proposes the following solution:

[0005] In a first aspect, this application provides a method for determining single-phase reactive power. The method includes: acquiring instantaneous voltage and current sampled values ​​of a single-phase circuit under test within an electromagnetic transient simulation model at a first sampling time and a second sampling time, wherein the first sampling time and the second sampling time are adjacent sampling times, and the first sampling time precedes the second sampling time; determining the original phase difference angle between the voltage and current of the single-phase circuit under test based on the polarity relationship and zero-crossing change characteristics of the instantaneous voltage and current sampled values; determining the effective voltage value of the single-phase circuit under test based on the instantaneous voltage sampled values, and determining the effective current value of the single-phase circuit under test based on the instantaneous current sampled values; and determining the single-phase reactive power of the single-phase circuit under test based on the effective voltage value, the effective current value, and the original phase difference angle.

[0006] This application only collects the instantaneous values ​​of voltage and current at two adjacent moments, eliminating the need to cache multi-cycle waveform data. The phase difference is directly calculated using signal polarity and zero-crossing characteristics, and reactive power is simultaneously calculated using the real-time calculated effective values ​​of voltage and current. This eliminates periodic delay at its source, enabling real-time reactive power measurement under electromagnetic transient simulation.

[0007] In conjunction with the first aspect, in one possible implementation, the phase difference identifier between the voltage and current of the single-phase circuit under test is determined based on the polarity relationship of the instantaneous voltage sample value and the zero-crossing change characteristics across time intervals; the original phase difference angle between the voltage and current of the single-phase circuit under test is determined based on the phase difference identifier.

[0008] This application breaks down the original phase difference solution into a two-stage process: qualitative judgment of phase difference identification and quantitative conversion of angle. First, it relies on polarity and zero-crossing features to complete the standardized classification of phase conditions, and then uniformly maps them into calculable angle values, transforming fuzzy time-series features into standardized quantitative parameters, thus avoiding the complex trigonometric function calculations brought about by directly analyzing the instantaneous waveform phase.

[0009] In conjunction with the first aspect, in one possible implementation, when the instantaneous voltage sample value and the instantaneous current sample value at the same sampling time have the same polarity, the phase difference identifier is set to the first identifier state; when the instantaneous current sample value undergoes a polarity reversal or reaches a zero-crossing state between the first sampling time and the second sampling time, the phase difference identifier is set to the second identifier state; when the instantaneous voltage sample value undergoes a polarity reversal or reaches a zero-crossing state between the first sampling time and the second sampling time, the phase difference identifier is set to the third identifier state.

[0010] This application classifies phase conditions using three mutually exclusive criteria: voltage and current instantaneous value polarity matching, and signal zero-crossing reversal across time intervals. Based on the physical constraint that synchronous zero-crossings will not occur under extremely small simulation step sizes, it ensures conflict-free decision logic. State identification is completed using only basic multiplication and comparison logic operations, eliminating the need for complex waveform fitting. Layered priority determination covers all simulation conditions—start-up, steady-state, and transient—eliminating the risk of computational interruptions due to lack of historical data or zero-crossing intervals. It maintains stable identifier output throughout the process, avoiding disordered phase reference transitions.

[0011] In conjunction with the first aspect, in one possible implementation, the preset reference angle is multiplied by the phase difference identifier to obtain the original phase difference angle between the voltage and current of the single-phase circuit under test.

[0012] The positive and negative symmetric mapping rule naturally matches the sign distinction logic of inductive and capacitive reactive power, and the angle interval strictly matches the physical range of the sinusoidal signal phase, so there will be no problem of phase offset scale imbalance.

[0013] In conjunction with the first aspect, in one possible implementation, the first filtering coefficient is determined based on the simulation step size and the filtering time constant; the instantaneous voltage sample value and the instantaneous current sample value are squared to obtain the squared voltage value and the squared current value; the squared voltage value and the squared current value are time-series iteratively filtered based on the first filtering coefficient to obtain the average voltage value and the average current value; the average voltage value and the average current value are amplitude restored to obtain the effective voltage value and the effective current value.

[0014] This application squares the instantaneous current, performs a time-series low-pass filter, and then takes the square root to obtain the effective value. By leveraging the equivalent root mean square integral effect of the first-order recursive mean, it eliminates the need for a sliding window to store multiple sampled values; it only needs to store the mean value from the previous step for iterative updates. The filter coefficients are matched with the simulation step size and time constant to achieve continuous filtering physical characteristics, which can smooth second harmonic fluctuations and sampling noise. At the same time, it does not have the output delay of more than half a cycle inherent in sliding windows, thus balancing the smoothness of effective value calculation and the speed of transient amplitude tracking.

[0015] In conjunction with the first aspect, in one possible implementation, the single-phase reactive power is calculated based on the phase correlation relationship corresponding to the fundamental reactive power, combined with the effective value of voltage, the effective value of current, and the original phase difference angle. The reactive power type of the single-phase circuit under test is determined according to the sign of the original phase difference angle. When the original phase difference angle is positive, the reactive power type of the single-phase circuit under test is inductive reactive power, and when the original phase difference angle is negative, the reactive power type of the single-phase circuit under test is capacitive reactive power.

[0016] This application utilizes the standard reactive power formula based on the sinusoidal product of phase difference to perform calculations, strictly adhering to the physical definition of single-phase AC reactive power exchange. Reactive power numerical solutions can be obtained using only basic multiplication and trigonometric operations. Simultaneously, reactive power types are distinguished by the positive or negative phase difference, eliminating the need for constructing additional orthogonal signals or decomposing harmonic components. The reactive power attributes of the load are directly mapped from the phase detection results, achieving integrated and synchronous output of both numerical magnitude and reactive power characteristics.

[0017] In conjunction with the first aspect, in one possible implementation, the second filtering coefficient is determined based on the simulation step size and the filtering time constant; the original phase difference angle is then subjected to time-weighted filtering based on the second filtering coefficient to obtain the filtered phase difference angle.

[0018] This application adds a time-weighted filtering stage after the discrete original phase difference calculation, and uses first-order recursive smoothing to eliminate the π / -π step jump caused by the identifier switching, thereby suppressing the synchronous oscillation of reactive power output.

[0019] Secondly, this application provides a single-phase reactive power determination device, which includes:

[0020] The acquisition module is used to acquire the instantaneous voltage and current sampling values ​​of the single-phase circuit under test in the electromagnetic transient simulation model at the first sampling time and the second sampling time. The first sampling time and the second sampling time are adjacent sampling times, and the first sampling time is before the second sampling time.

[0021] The first determining module is used to determine the original phase difference angle between the voltage and current of the single-phase circuit under test based on the polarity relationship of the instantaneous voltage sample value and the zero-crossing change characteristics across time.

[0022] The second determining module is used to determine the effective value of the voltage of the single-phase circuit under test based on the instantaneous voltage sampling value, and to determine the effective value of the current of the single-phase circuit under test based on the instantaneous current sampling value.

[0023] The third determining module is used to determine the single-phase reactive power of the single-phase circuit under test based on the effective value of voltage, the effective value of current, and the original phase difference angle.

[0024] To achieve the above objectives, according to a third aspect of this application, a storage medium is provided, the storage medium including a stored program, wherein, when the program is running, the device where the storage medium is located is controlled to execute the single-phase reactive power determination method of the first aspect described above.

[0025] To achieve the above objectives, according to a fourth aspect of this application, an electronic device is provided, the device including at least one processor, and at least one memory and bus connected to the processor; wherein the processor and memory communicate with each other through the bus; the processor is used to call program instructions in the memory to execute the single-phase reactive power determination method of the first aspect described above.

[0026] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description

[0027] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:

[0028] Figure 1 A flowchart illustrating a method for determining single-phase reactive power according to an embodiment of this application is shown.

[0029] Figure 2A flowchart illustrating a method for determining the original phase difference angle provided in an embodiment of this application is shown.

[0030] Figure 3 A schematic diagram of a test single-phase circuit provided in an embodiment of this application is shown;

[0031] Figure 4 This diagram shows a comparison of reactive power measurement waveforms under the condition of fundamental wave superimposed with third harmonic.

[0032] Figure 5 This diagram shows the reactive power measurement error curve under the condition of fundamental wave superposition with third harmonic;

[0033] Figure 6 A schematic diagram of a current waveform with sawtooth distortion is shown.

[0034] Figure 7 This diagram shows a comparison of reactive power calculation waveforms under waveform distortion conditions.

[0035] Figure 8 This diagram illustrates the reactive power measurement error curve under waveform distortion conditions.

[0036] Figure 9 This diagram shows a comparison of reactive power measurement waveforms under the condition of sudden change in current amplitude.

[0037] Figure 10 This diagram illustrates the reactive power measurement error curve under conditions of sudden changes in current amplitude.

[0038] Figure 11 A flowchart illustrating a single-phase static var compensation control method provided in an embodiment of this application is shown.

[0039] Figure 12 This paper shows a schematic diagram of the structure of a single-phase reactive power determination device provided in an embodiment of this application;

[0040] Figure 13 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation

[0041] Exemplary embodiments of the present application will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this application will be thorough and complete, and will fully convey the scope of the present application to those skilled in the art.

[0042] In the embodiments of this application, the terms "first," "second," etc., do not have a logical or temporal dependency, nor do they limit the quantity or execution order. It should also be understood that although the following description uses the terms "first," "second," etc., to describe various elements, these elements should not be limited by the terms. These terms are merely used to distinguish one element from another.

[0043] In this application, the term "at least one" means one or more, and the term "multiple" means two or more.

[0044] It should also be understood that the term “if” can be interpreted as “when” or “upon”, or “in response to determination” or “in response to detection”. Similarly, depending on the context, the phrase “if determination…” or “if detection [the stated condition or event]” can be interpreted as “when determination…” or “in response to determination…” or “when detection [the stated condition or event]” or “in response to detection [the stated condition or event]”.

[0045] In single-phase AC electrical circuits, reactive power is a core electrical quantity characterizing the scale of periodic electric and magnetic field energy exchange between the power source and energy storage loads. This physical quantity does not output effective work, but it is an essential electrical parameter for establishing alternating electromagnetic fields in power equipment such as transformers, asynchronous motors, and power capacitors. Given the role of reactive power in power analysis, real-time reactive power calculation of the tested single-phase circuit in electromagnetic transient simulation scenarios is of paramount engineering necessity. Electromagnetic transient simulation uses microsecond-level extremely small simulation steps to reproduce short-term electrical abrupt changes such as short-circuit faults, load switching, and new energy grid connection. During the simulation process, voltage and current are prone to non-steady-state phenomena such as amplitude jumps, rapid phase shifts, and waveform distortion. If the reactive power of the circuit cannot be accurately obtained synchronously with each simulation step, it is impossible to capture the instantaneous fluctuations of reactive power flow during transient processes, directly causing distortion of reactive power compensation simulation logic, misjudgment of transient voltage instability, and failure of reactive power characteristic analysis of distorted loads.

[0046] While current reactive power measurement methods used in electromagnetic transient simulation can achieve basic numerical solutions, their inherent architectural limitations make them ill-suited for the aforementioned real-time measurement requirements. Existing mainstream solutions fall into three categories: Fourier frequency domain analysis, Hilbert orthogonal construction, and phase-locked loop (PLL) coupled sliding window averaging. The Fourier algorithm requires a complete power frequency cycle sampling window to extract the spectrum, suffers from inherent output delay, and generates spectral leakage errors when frequency shifts occur. Furthermore, complex number operations consume significant simulation computational resources. The Hilbert transform relies on an integral link to generate orthogonal phase-shifted signals, introducing fixed phase deviations and dynamic lags in the phase-shifting stage. Measurement accuracy drops drastically under waveform distortion conditions, and filter parameter tuning is cumbersome. The PLL sliding window scheme relies on closed-loop feedback to track the phase, but is prone to loss of lock under transient disturbances and exhibits slow convergence. The sliding window averaging mechanism also suffers from data lag. All three traditional techniques rely on multi-cycle data caching, integral operations, or closed-loop feedback links, failing to simultaneously meet the real-time measurement requirements of low computational power, zero latency, and resistance to waveform distortion in electromagnetic transient simulation.

[0047] Based on this, this application provides a method for determining single-phase reactive power. The method for determining single-phase reactive power is described in detail below with reference to the accompanying drawings. Figure 1 This is a flowchart illustrating a method for determining single-phase reactive power provided in this application. Specifically, it includes the following steps:

[0048] Step 110: Obtain the instantaneous voltage and current sampling values ​​of the single-phase circuit under test in the electromagnetic transient simulation model at the first sampling time and the second sampling time.

[0049] This implementation method relies on electromagnetic transient simulation programs (such as PSCAD, EMTP, and MATLAB / Simulink power simulation modules) for numerical iterative calculations. A uniform, fixed simulation step size is pre-configured before the simulation runs. This step size is much smaller than half a cycle of the power frequency signal, ensuring that the voltage and current waveforms do not undergo drastic changes across a complete half cycle between two adjacent samplings, thus providing a basic premise for this application to complete phase discrimination based solely on the instantaneous values ​​at two moments.

[0050] Each time the simulation program completes a round of timing iteration, it corresponds to a sampling time. The time when the iteration is executed first in the timing sequence is defined as the first sampling time. The time corresponding to the next adjacent iteration is defined as the second sampling time. These two constitute a pair of adjacent sampling timing sequences. For the selected single-phase circuit under test in the simulation model, at the first sampling time... Read the instantaneous sampled value of the voltage at the loop port. Instantaneous sampling value of series branch current And write it to the memory cache for temporary storage. Wait until the program runs to the second sampling time. Simultaneously, the instantaneous voltage sampling value of the current port of the same single-phase circuit under test is read. Instantaneous current sampling value .

[0051] The two sets of instantaneous sampled values ​​are synchronously transmitted to the cache interface of the reactive power measurement logic in this application. The entire process only occupies two sets of four-element temporary storage units, eliminating the need to allocate a large-capacity storage array to cache multiple cycles of waveform data, thus significantly reducing the memory usage of the simulation platform. The sampled value reading process is synchronous and parallel with the simulation timing iteration, with no data reading delay. This ensures that the instantaneous voltage and current values ​​at each adjacent moment are the true original values ​​under the current simulation timing, without interpolation or prediction correction operations. This guarantees the original accuracy of subsequent phase discrimination, effective value calculation, and reactive power solution from the data source level.

[0052] If the simulation model requires parallel measurement of multiple single-phase circuits, a storage cache can be independently allocated to each single-phase circuit under test. The multiple sampling data do not interfere with each other, and the instantaneous value acquisition of multiple circuits is completed synchronously, which is suitable for large-scale power grid electromagnetic transient parallel simulation scenarios.

[0053] Step 120: Determine the original phase difference angle between the voltage and current of the single-phase circuit under test based on the polarity relationship of the instantaneous voltage sampling value and the zero-crossing change characteristics across time intervals.

[0054] After reading two sets of instantaneous voltage and current sample values ​​at adjacent time points in step 110, two sets of core discriminative features can be extracted: First, the instantaneous value polarity, referring to the positive or negative sign of the instantaneous voltage and current sample values ​​at the same sampling time; a sample value greater than 0 indicates positive polarity, and less than 0 indicates negative polarity. Second, the zero-crossing change characteristic across time points, referring to the zero-crossing reversal behavior of the instantaneous voltage or current value from positive to negative and vice versa between adjacent first and second sampling times. If the signs of the sample values ​​at consecutive time points are opposite, it indicates that the signal has crossed zero within the interval. These two types of features can qualitatively distinguish between three phase conditions: voltage and current in phase, current leading, and voltage leading.

[0055] From the perspective of the basic calculation logic of single-phase AC circuits, the solution of reactive power requires substituting the phase difference parameter into the standardized algebraic formula to complete the calculation. The qualitative judgment results obtained by relying solely on polarity difference and zero crossing order do not have the quantitative attributes that can be directly used in numerical iteration and cannot support the complete power calculation process. Therefore, it is necessary to transform the qualitative phase relationship of leading, lagging, and in-phase into standardized angle values ​​with positive and negative attributes.

[0056] From the perspective of the operational characteristics of electromagnetic transient simulation, electrical disturbances such as short-circuit faults, branch switching, and fluctuations in renewable energy output during the simulation process can all change the phase relationship and reactive power flow of the circuit in a very short time. Commonly used phase extraction methods in the industry, such as Fourier spectrum analysis, Hilbert quadrature phase shifting, and phase-locked loop (PLL) closed-loop tracking, all require storing a sampling sequence of at least one complete power frequency cycle. The complex operations of complex decomposition, integral iteration, and closed-loop feedback to analyze phase information result in a fixed output delay due to data caching and computation, making it impossible to synchronously refresh the phase results with each simulation step. This makes it difficult to accurately reproduce the instantaneous changes in reactive power during transient processes. Simultaneously, multi-cycle data caching and complex mathematical operations continuously consume the simulation platform's memory and processor resources. When the simulation model contains a large number of single-phase circuits being measured in parallel, the overall computational efficiency will significantly decrease. Based on the above computational requirements and scenario constraints, this application abandons the traditional phase detection approach that relies on multi-cycle sampling data and constructs phase quantization logic solely based on two adjacent sets of instantaneous sampling values.

[0057] To ensure a clear and orderly computation process, this step is divided into two progressive sub-processes. The first stage generates a unique phase difference identifier representing the phase condition based on the sampling features, completing the standardized encapsulation of the qualitative phase state. The second stage then maps and converts the identifier into a quantized original phase difference angle that can participate in filtering and power calculation. The specific implementation method is as follows.

[0058] Step 210: Determine the phase difference identifier between the voltage and current of the single-phase circuit under test based on the polarity relationship of the instantaneous voltage sampling value and the zero-crossing change characteristics across time intervals.

[0059] This step, as the first sub-process of phase quantization, primarily transforms the polarity and zero-crossing timing characteristics carried by the two sets of instantaneous sampled values ​​into a unified and standardized phase difference identifier. The entire operation utilizes the instantaneous values ​​cached in step 110 from the previous simulation moment. , Instantaneous value at the current simulation moment , Perform logical judgments.

[0060] For a single-phase sinusoidal AC circuit, the relative phase state of voltage and current always falls within three categories: in-phase, current leading, and voltage leading. These three categories have a strict correspondence with signal polarity and zero-crossing behavior. When polarity is consistent at the same moment, it corresponds to the in-phase condition. When a certain signal completes the zero-crossing reversal first, it corresponds to the phase leading of that signal.

[0061] To achieve standardized encapsulation of qualitative phase states, this step predefines three independent and non-overlapping identification states, corresponding to three phase conditions: the first identification state has an identification value of 0, which is used to characterize the operating condition where the voltage and current of the measured single-phase circuit are in phase; the second identification state has an identification value of -1, which is used to characterize the operating condition where the current phase of the measured single-phase circuit leads the voltage; and the third identification state has an identification value of 1, which is used to characterize the operating condition where the voltage phase of the measured single-phase circuit leads the current.

[0062] There is a strict one-to-one correspondence between the three types of identifiers and the polarity and zero-crossing behavior of the sampled signals. Consistent polarity at the same moment corresponds to in-phase operation, and if a signal completes its zero-crossing reversal first, its corresponding phase is ahead. This correspondence is stable and avoids decision conflicts because the electromagnetic transient simulation in this application uses an extremely small simulation step size. The time interval between adjacent samples is much smaller than half a cycle of the power frequency signal. Extreme conditions where voltage and current simultaneously cross zero points will not occur within the same sampling interval. Therefore, the decision conditions corresponding to the three phase states naturally form a mutually exclusive relationship. Only one type of condition will be determined in a single simulation iteration, physically avoiding logical contradictions caused by simultaneous matching of multiple states and ensuring that each judgment outputs a unique and accurate identifier result.

[0063] The complete operational cycle of electromagnetic transient simulation encompasses multiple stages, including initialization, steady-state operation without disturbance, and transient disturbance fluctuations. Relying solely on basic polarity and zero-crossing judgments cannot cover all operational scenarios. The initial iteration of the simulation lacks historical sampling data for cross-time comparison. During steady-state operation, voltage and current polarity do not reverse within adjacent intervals, while zero-crossing events frequently occur during the transient phase. Using only a single judgment rule can lead to issues such as no effective output and disordered state transitions under special operating conditions, further causing numerical oscillations or even process interruptions in subsequent angle conversions and power calculations. Therefore, this step designs a hierarchical, multi-branch verification architecture. Each branch executes condition matching sequentially according to a fixed priority, triggering only one assignment branch or state-holding branch per iteration, ensuring a stable and effective phase difference indicator is output at any point throughout the simulation.

[0064] The highest priority branch is the simulation initial decision branch, which is used to handle the special scenario of the first iteration of the simulation. When this timing iteration is the first calculation after the simulation program starts, the system memory has not yet stored the historical sampling data of the previous cycle, and there is no data condition for cross-interval zero-crossing comparison. At this time, the phase difference flag is directly set to the first flag state, and the voltage and current are in phase as the reference phase state in the initial stage of the simulation. This ensures that the entire calculation process can start smoothly and avoids the first calculation from running abnormally due to the lack of decision basis.

[0065] After completing the initial scenario verification, if the current iteration is not the first round of simulation, the program enters the in-phase condition judgment branch. The program calculates the product of the instantaneous voltage and current values ​​at the current moment, and determines whether their polarities are consistent by the sign of the product. When the product is greater than zero, it indicates that the current voltage and current are both positive or both negative, and the waveforms are synchronously in the rising or falling phase, with no phase shift between them, corresponding to the in-phase electrical condition. At this time, the phase difference flag is set to the first flag state, and after the condition is matched, the entire judgment process of this round ends directly, and the verification of subsequent branches is not executed.

[0066] If the conditions for determining the in-phase condition are not met, the program enters the current-leading condition determination branch. The program compares the sign change of the instantaneous current value from the previous moment to the current moment, and determines whether the current has undergone a zero-crossing reversal within the sampling interval by checking if the product of the two is less than or equal to zero. When this condition is met, it indicates that the current signal completes the positive-to-negative switching before the voltage signal, and the current phase leads the voltage, corresponding to the current-leading electrical condition. At this time, the phase difference flag is set to the second flag state, and the subsequent judgment process in this round is terminated after the condition is matched.

[0067] If the current-leading condition judgment condition is still not met, the program enters the voltage-leading condition judgment branch. The program compares the sign change of the instantaneous voltage value at the previous moment with that at the current moment, and determines whether the voltage has undergone a zero-crossing reversal within the sampling interval by checking whether the product of the two is less than or equal to zero. When this judgment condition is met, it means that the voltage signal completes the positive-to-negative switching before the current signal, and the voltage phase leads the current, corresponding to the voltage-leading electrical condition. At this time, the phase difference flag is set to the third flag state, completing all verifications for conventional zero-crossing related scenarios.

[0068] If none of the conditions in the four assignment branches mentioned above are met, the program enters the steady-state fallback branch. This branch corresponds to the steady-state, disturbance-free operation scenario of the power grid. At this time, the voltage and current in adjacent sampling intervals have not undergone polarity reversal, and their relative phase relationship has not changed compared to the previous iteration cycle, so there is no need to re-execute the complete discrimination process. The program directly retrieves the phase difference flag from the previous iteration cache as the output result of this round, which reduces the computational power consumption caused by repeated calculations and avoids frequent flag state jumps that may be caused by repeated discrimination.

[0069] The aforementioned layered, multi-branch verification architecture enhances the performance and adaptability of the phase discrimination process from multiple dimensions. The branch design, covering all operating conditions, fills the logical blind spots of single-judgment rules, continuously outputting valid identifiers from simulation startup to steady-state and transient phases. This avoids measurement interruptions and numerical distortions under special operating conditions, improving the overall algorithm's stability. The simplified basic computational logic significantly reduces the computational overhead of single-step iterations, eliminating the need for large-capacity memory storage of waveform data. Even in multi-loop parallel simulation scenarios, it does not slow down the overall simulation speed, fully adapting to the real-time requirements of electromagnetic transient simulations. Mutually exclusive judgment conditions combined with layer-by-layer termination verification rules ensure that each judgment outputs a unique identifier, eliminating conflicts between multiple operating conditions and providing clear and unambiguous qualitative input for subsequent angle conversion. The steady-state holding mechanism further optimizes the computational efficiency of the steady-state operation phase while suppressing irregular fluctuations in phase identifiers, indirectly improving the smoothness of subsequent reactive power measurement results, better meeting the needs of engineering observation and analysis.

[0070] Step 220: Determine the original phase difference angle between the voltage and current of the single-phase circuit under test based on the phase difference indicator.

[0071] This step, as the second-level sub-process of phase quantization, follows the phase difference identifier output from step 210, completing the conversion from qualitative state identifier to quantized angle value, and finally outputting the original phase difference angle with positive and negative attributes that can be directly substituted into algebraic formulas for calculation. The phase difference identifier can only represent the category of phase relative relationship and does not have a quantization dimension that can participate in numerical iteration calculations. Therefore, it cannot be directly substituted into the reactive power calculation formula. Thus, it is necessary to convert the discrete identifier into a continuously calculable angle parameter through standardization conversion.

[0072] Considering the differences in computing power constraints and accuracy requirements in different simulation scenarios, this step can adopt a differentiated conversion path to adapt to simulation application scenarios of different scales and accuracy requirements while ensuring real-time output of microsteps.

[0073] In one implementation, a preset reference angle is multiplied by a phase difference identifier to obtain the original phase difference angle between the voltage and current of the single-phase circuit under test. This conversion path has extremely simple calculation logic, performing only a single multiplication operation throughout the entire process, without additional iterations or complex fitting operations, resulting in extremely low single-step calculation latency, and is adaptable to ultra-large-scale multi-circuit parallel simulation scenarios.

[0074] Phase difference identifier output in step 210 It includes three discrete values, each corresponding to one of three phase conditions: the first indicator state is 0, corresponding to the voltage and current being in phase; the second indicator state is -1, corresponding to the current phase leading the voltage; and the third indicator state is 1, corresponding to the voltage phase leading the current.

[0075] In this implementation, π is pre-selected as the phase difference conversion reference coefficient (i.e., the preset reference angle). Since the phase of a sinusoidal AC signal changes periodically with time, each zero-crossing reversal of a positive and negative half-cycle corresponds to a phase change of π radians. Using π as the conversion reference ensures dimensional matching with the physical phase change during zero-crossing, guaranteeing that the output angle conforms to the physical definition of phase. Simultaneously, the symmetrical positive and negative reference amplitudes correspond one-to-one with the lead and lag phase conditions, avoiding inconsistencies in quantization scales in the lead and lag directions. This also provides initial quantization values ​​within a reasonable physical range for subsequent timing smoothing filtering, preventing excessive deviation of the initial amplitude from the actual range and thus slowing filter convergence. The original phase difference angle is directly obtained by multiplying the identifier value by the reference coefficient. The conversion relationships are as follows: .

[0076] When the phase difference is identified in the first state, the original phase difference angle is 0, indicating no phase shift between voltage and current. When the phase difference is identified in the second state, the original phase difference angle is -π, with the negative sign indicating the current-leading phase attribute, and π being the reference phase shift amplitude. When the phase difference is identified in the third state, the original phase difference angle is π, with the positive sign indicating the voltage-leading phase attribute, and the amplitude remaining symmetrical with the current-leading condition.

[0077] The original phase difference angle obtained in this method is a preliminary quantized reference phase value. The angle sign strictly matches the phase lead-lag attribute, and it can be directly input into the subsequent timing smoothing filtering stage to complete the gradual correction of the amplitude. Under the premise of ensuring synchronous output in each simulation step, the filtering iteration converges to the actual phase offset. When step 210 triggers the fallback hold logic due to the steady-state zero-crossing condition and the phase difference indicator is consistent with the previous cycle, the original phase difference angle output in this embodiment synchronously maintains the value of the previous cycle, maintains the continuity of the output timing, and avoids meaningless jumps in the value under steady state.

[0078] In another implementation, the original phase difference angle is solved by zero-crossing interpolation recursive calculation. This method breaks through the limitation that discrete identifiers can only output three fixed angles. Based on only two adjacent sets of sampled values ​​and without adding multi-cycle data buffers, it introduces linear interpolation operation at the zero-crossing position to solve for the precise zero-crossing time. Then, combined with the reference time recursive mechanism, it is converted to obtain the continuous original phase difference angle. It effectively improves the precision of phase quantization with extremely low computational power increment and is suitable for simulation scenarios with higher requirements for the accuracy of transient phase measurement.

[0079] The complete calculation process relies solely on the instantaneous value cached in step 110 from the previous moment. , Instantaneous value at the current moment , The process is performed in stages, combining the phase difference identifier output in step 210. Because this application uses a very small simulation step size, the signal amplitude changes approximately linearly within adjacent sampling intervals. The calculation error caused by linear interpolation is negligible, ensuring the accuracy of the solution at zero-crossing moments.

[0080] The first stage of the calculation involves interpolation at the zero-crossing moment of the target signal. When step 210 determines that the current has undergone a zero-crossing reversal and the phase difference indicator is in the second indicator state, linear interpolation is performed based on the instantaneous current values ​​at the two moments before and after the zero-crossing to calculate the precise moment when the current actually crosses zero. The simulation is assumed to have a fixed step size of [missing value]. ,Right now and The time interval is According to the linear proportional relationship, at the moment the current crosses zero... Compared to the previous moment time offset satisfy: Therefore, the precise zero-crossing time of the current can be derived: Similarly, when step 210 determines that the voltage has undergone a zero-crossing reversal and the phase difference indicator is in the third indicator state, the precise zero-crossing time of the voltage is calculated using the same linear interpolation method. .

[0081] The second stage of the calculation involves the quantization and conversion of the phase difference angle. Based on the physical characteristics of a sinusoidal periodic signal, the phase offset is proportional to the zero-crossing time difference; the phase difference angle is equal to the ratio of the zero-crossing time difference to the power frequency period T multiplied by... Simultaneously, the sign of the angle is determined by combining the phase difference indicator. During the calculation, only the zero-crossing reference time of the previous signal on the opposite side needs to be cached; the entire waveform data does not need to be stored. When the current leads (i.e., in the second indicator state), the previous voltage zero-crossing reference time is used. Using the time base, the original phase difference angle is: When the voltage leads (i.e., in the third indicator state), it is at the time of the previous current zero crossing. Using the time base, the original phase difference angle is: When the phase difference is identified as the first identification state, i.e., in phase, the original phase difference angle is 0.

[0082] After each zero-crossing time calculation is completed, the reference time register of the corresponding signal is updated synchronously to provide a time reference for the phase difference calculation when the opposite signal crosses zero again, thus forming a recursive update mechanism.

[0083] This implementation only adds storage overhead for a single moment value, and the computational load increases only slightly with linear interpolation and scaling operations. The overall computing power remains significantly lower than traditional full-cycle phase detection schemes. The resulting raw phase difference angle is a continuously changing value, which more closely approximates the actual phase shift, resulting in faster convergence of subsequent time-series smoothing filtering stages and better phase tracking performance during transient disturbances. When step 210 triggers the fallback hold logic and there are no zero-crossing events in the current sampling interval, this implementation directly uses the existing raw phase difference angle value without triggering interpolation operations. This reduces redundant computational power consumption in steady state and maintains the stability of the angle output.

[0084] After obtaining the original phase difference angle, due to the discrete value characteristics of the phase difference identifier itself, the original phase difference angle naturally exhibits a step-like abrupt change. Since the phase difference identifier only contains three discrete values: -1, 0, and 1, the corresponding mapped original phase difference angle can only be output... 0 With three fixed amplitude levels and no continuous transition between intermediate values, this is a typical discrete quantization output. Within the steady-state range where no zero-crossing reversal of voltage or current is detected, the phase difference indicator maintains a constant value, and the original phase difference angle also remains at a fixed amplitude, exhibiting a horizontal straight-line characteristic in the time domain. When the system reaches the zero-crossing detection moment, i.e., when step 210 detects a zero-crossing reversal of voltage or current and a phase difference indicator level change, the original phase difference angle jumps directly from the current fixed amplitude to another fixed amplitude level without a continuous gradual transition between the two levels. Therefore, the overall time-domain waveform exhibits a step-like abrupt change characteristic. Directly substituting the original phase difference angle with this abrupt characteristic into the reactive power calculation formula will cause synchronous step-like jitter in the final measurement result, which is detrimental to the continuous observation and analysis of reactive power characteristics under steady-state conditions.

[0085] To smooth the aforementioned step-like transitions and suppress numerical oscillations caused by discrete jumps, this application employs a first-order low-pass filter to perform time-weighted smoothing of the original phase difference angle. This filtering method only requires storing the filtering result from the previous time step, and the computational logic is a single weighted summation, resulting in extremely low computational overhead. Furthermore, it can soften the step edges while preserving the overall phase change trend, thus meeting the real-time operation requirements of micro-step electromagnetic transient simulations.

[0086] In one implementation, a second filtering coefficient is determined based on the simulation step size and the filtering time constant; the original phase difference angle is then subjected to time-weighted filtering based on the second filtering coefficient to obtain the filtered phase difference angle.

[0087] The filtering time constant directly determines the smoothing strength and response speed. Using a fixed filtering time constant presents an inherent contradiction: it's difficult to simultaneously achieve both steady-state smoothing and transient tracking speed. A larger time constant results in better steady-state step suppression, but slower phase tracking convergence after transient disturbances, easily leading to phase lag. A smaller time constant results in rapid transient response, but insufficient smoothing of steady-state step transitions, leaving residual small oscillations.

[0088] To resolve this contradiction, in one implementation, an adaptive dynamic adjustment method based on multi-feature fusion is used to determine the filtering time constant. The time constant value is adjusted in real time in conjunction with the loop operating conditions at the current simulation moment. Under steady-state conditions, the smoothing capability is enhanced, and under transient conditions, the tracking speed is improved, thereby achieving a dynamic balance between smoothing effect and response speed. The specific implementation process is as follows.

[0089] The first step involves extracting three types of operating condition characterization parameters to construct a multi-dimensional feature input system. The first type is the phase difference change rate parameter. Using the time interval between two consecutive zero-crossing events as the statistical period, the amplitude change of the original phase difference angle corresponding to the two zero-crossing moments is calculated. The ratio of the amplitude change to the statistical period is taken as the phase difference change rate. This parameter directly reflects the overall speed of phase shift change. A larger change rate indicates a more drastic adjustment of the circuit load or operating state, and a greater tendency towards transient conditions. A smaller change rate indicates a more stable phase state, and a greater tendency towards steady-state conditions. The second type is the zero-crossing deviation parameter. A sliding time window with a length of several power frequency cycles is set, and the total number of actual zero-crossing reversals of the voltage and current signals within the window is counted. The ratio of the actual number of zero-crossings to the theoretical number of zero-crossings of the pure power frequency signal is taken as the zero-crossing deviation coefficient. This parameter reflects the degree of signal disturbance and distortion. The closer the ratio is to 1, the closer the signal is to a standard power frequency sine wave, and the more stable the operating condition. The further the ratio deviates from 1, the more severe the transient disturbance and harmonic distortion. The third type is the phase residual parameter. This calculates the absolute difference between the original phase difference angle at the current moment and the filtered phase difference angle at the previous moment. This parameter reflects the real-time deviation between the filtered output and the original sampled value. A larger difference indicates a higher probability of abrupt changes in the phase state, requiring faster tracking. A smaller difference indicates a more stable phase state, maintaining a stronger smoothing intensity.

[0090] The second step involves designing a dedicated membership function for each type of parameter, completing the mapping transformation from single feature to steady-state membership. Parameters of different dimensions are uniformly mapped to the 0-1 range. A steady-state membership value closer to 1 indicates a condition closer to steady state, while a value closer to 0 indicates a condition closer to transient state. For the phase difference rate of change, a half-trapezoidal membership function is used: when the rate of change is less than a preset steady-state threshold, the steady-state membership value is 1; when the rate of change is greater than a preset transient threshold, the steady-state membership value is 0; and when it falls between these two thresholds, it is mapped according to a linear decreasing law, ensuring a continuous and smooth membership value within the transition range. For the zero-crossing deviation coefficient, a symmetrical membership function is used: centered on the pure power frequency ideal state with a coefficient equal to 1, the smaller the deviation, the higher the steady-state membership value. When the deviation exceeds a preset limit, the membership value drops to 0. This symmetrical structure can simultaneously adapt to both excessive and insufficient zero-crossing counts in abnormal operating conditions. For the phase residual parameter, an exponential membership function is adopted: the smaller the residual, the higher the membership; when the residual increases, the membership decays rapidly according to an exponential law, which can quickly identify transient conditions at the moment of phase change and adapt to the rapid response requirements under sudden change scenarios.

[0091] The third step involves multi-feature weighted fusion and nonlinear power mapping to generate the real-time filtering time constant. Differential weight coefficients are configured for the three types of steady-state membership, which can be preset according to the emphasis of the simulation scenario. The weighted sum is then used to obtain the comprehensive steady-state membership. The upper and lower limits of the filter time constant are preset, which are the minimum time constant values. With the maximum time constant ,in To meet the need for rapid tracking under transient operating conditions, This addresses the strong smoothing requirement under steady-state operating conditions. The real-time filtering time constant is calculated using a nonlinear power-law mapping relationship. : , where k is a nonlinear adjustment coefficient, with a value greater than 1. This coefficient is used to enhance the distinction between steady-state and transient regions, making the time constant closer to the upper limit when the operating condition is near steady state, thus fully utilizing the smoothing effect. During transient abrupt changes, the comprehensive membership degree decreases rapidly, and the time constant quickly falls back to near the lower limit, ensuring tracking speed and avoiding the problem of slow parameter adjustment in the transition region.

[0092] The fourth step is to apply a time constant amplitude limiting and smoothing constraint. To avoid the filter output oscillation caused by abrupt and reverse time constant changes between adjacent simulation steps, a single-step adjustment amplitude limit is applied to the calculated real-time time constant, limiting the maximum increase or decrease of the time constant in each step. This ensures that the time constant transitions smoothly and continuously with changes in operating conditions, guaranteeing the stability of the filter output.

[0093] After determining the filtering time constant, the first-order low-pass filter coefficients are calculated using a fixed simulation step size in electromagnetic transient simulation. The first-order low-pass filter coefficients are calculated using an exponential discretization formula derived from the zero-pole matching discretization of the continuous-domain first-order low-pass transfer function. This formula accurately reproduces the time-domain attenuation characteristics of continuous low-pass filtering. Even with slight fluctuations in the simulation step size, the physical meaning of the filtering time constant remains strictly consistent, and no additional time-domain deviation is introduced due to discretization. The calculation formula is as follows: ,in Here, T is the fixed simulation step size for electromagnetic transient simulation, and T is the previously determined filtering time constant. In scenarios with strong computational constraints and low requirements for coefficient accuracy, this exponential approximation can also be used, relying on the first-order Taylor expansion of the exponential function, when... When the value is much smaller than T, the exponentiation is simplified to fractional operations, for example, approximated as... or further simplified to It eliminates exponential operations at the cost of a small loss of accuracy, further reducing the computational overhead per step and adapting to ultra-large-scale multi-loop parallel simulation scenarios.

[0094] After obtaining the first-order low-pass filter coefficients, a time-weighted recursive filter operation is performed on the original phase difference angle based on these coefficients. The filtered phase difference angle is obtained by iterating cycle by cycle. The calculation formula is as follows: ,in, The filtered phase difference angle is the value from the previous simulation time. This is the original phase difference angle obtained at the current moment. When the simulation starts the first iteration, the initial original phase difference angle output from the previous step is used as the initial value for filtering to ensure that the first round of calculation has valid input and avoid calculation anomalies.

[0095] After the first-order low-pass filtering process described above, the step-like jumps in the original phase difference angle are transformed into smooth, gradual transitions. High-frequency small-amplitude jitter caused by sampling and quantization noise is also effectively suppressed. The output filtered phase difference angle value is stable within the range of -π to π, consistent with the physical range of the original phase difference angle. This filtering scheme is a single-state recursive operation, requiring only the storage of the filtering result from the previous moment and a small amount of feature statistics. It does not require caching multi-cycle historical waveforms, resulting in extremely low memory usage and no additional storage burden on the simulation platform. The adaptive time constant mechanism allows the filtering performance to dynamically adapt to the operating conditions. During steady-state operation, a large time constant is maintained to effectively suppress the step-like oscillations caused by discrete jumps. When transient disturbances occur, the time constant is quickly reduced to accelerate phase tracking convergence and reduce phase lag deviation. This balances steady-state smoothing accuracy and transient response performance without significantly increasing computational overhead. The filtered phase difference angle has both clear positive and negative phase attributes and continuous and smooth numerical characteristics. It can be directly substituted into the subsequent reactive power calculation formula, which can significantly reduce the irregular oscillation of reactive power output values ​​and improve the engineering observation value and analysis accuracy of simulation results.

[0096] Step 130: Determine the effective voltage value of the single-phase circuit under test based on the instantaneous voltage sampling value, and determine the effective current value of the single-phase circuit under test based on the instantaneous current sampling value.

[0097] The RMS values ​​of voltage and current are key amplitude parameters for single-phase reactive power calculation, and their accuracy directly affects the reliability of the final reactive power measurement result. From the perspective of the operational characteristics of electromagnetic transient simulation, voltage and current signals are output step-by-step in the form of instantaneous sampled values. During transient disturbances, the signal amplitude may fluctuate rapidly. The traditional whole-cycle sampling and accumulation method for RMS calculation requires caching the sampled data for the entire cycle, which not only consumes a lot of memory resources but also introduces an output delay of at least one power frequency cycle, making it unsuitable for the real-time iterative requirements of micro-step simulation. Therefore, this step constructs a time-series recursive RMS value solution logic based on instantaneous sampled values, eliminating the need to store the entire waveform data and keeping the single-step computational load low. Different recursive implementation paths can be adopted to address the accuracy requirements and computational constraints of different simulation scenarios.

[0098] In one implementation, a first filtering coefficient is determined based on the simulation step size and the filtering time constant; the instantaneous voltage sample value and the instantaneous current sample value are squared to obtain the squared voltage value and the squared current value; the squared voltage value and the squared current value are time-series iteratively filtered based on the first filtering coefficient to obtain the average voltage value and the average current value; the average voltage value and the average current value are amplitude restored to obtain the effective voltage value and the effective current value.

[0099] First, the instantaneous voltage and current sample values ​​are squared to obtain the squared voltage and current values ​​at the corresponding times. For the current sampling time... The instantaneous voltage sampling value is The square value of the voltage is obtained after square transformation. The instantaneous current sampling value is The square value of the current is obtained after square transformation. The squaring operation can convert all alternating positive and negative AC signals into non-negative values, enabling subsequent mean filtering to equivalently complete the integral averaging stage in the root mean square operation, thus providing a computational basis for the final solution of the effective value.

[0100] Subsequently, the first filter coefficients, i.e., the first-order low-pass filter coefficients, are determined based on the simulation step size and the filter time constant. The coefficient is calculated using an exponential discretization relationship, derived from the precise discretization derivation of the first-order low-pass transfer function in the continuous domain. It can rigorously reproduce the time-domain attenuation characteristics of analog low-pass circuits. The calculation formula is as follows: Where Δt is the fixed simulation step size for electromagnetic transient simulation, and T is the filtering time constant. The method for determining this filtering time constant is consistent with that for the phase difference angle filtering stage mentioned above. It can be a fixed preset value or dynamically adjusted adaptively according to simulation requirements, which will not be elaborated here. In scenarios with strong computational constraints and low requirements for coefficient accuracy, this exponential approximation can also be used to eliminate exponential calculations with a small loss of accuracy, further reducing the computational cost per step.

[0101] After obtaining the first filter coefficient, a time-series iterative first-order low-pass filter is performed on the squared voltage value and the squared current value based on this coefficient, respectively, to obtain the mean voltage and mean current values. Mean voltage value The recursive calculation formula is: Average current The recursive calculation formula is: ,in This is the filtered value of the squared voltage at the previous sampling time. This is the current squared filter value from the previous sampling time. When starting the first iteration of the simulation, the squared value corresponding to the first sampling time is used as the initial value for the squared filter to ensure valid input for the first round of calculations and avoid numerical anomalies during the startup phase. Through cycle-by-cycle weighted recursive filtering, the second harmonic alternating component and high-frequency noise in the squared value are gradually filtered out, and the output mean value can stably reflect the long-term average level of the signal square, effectively completing the integral averaging operation defined in the root mean square definition.

[0102] Finally, square root operations are performed on the average voltage and average current values ​​respectively to restore the amplitude, yielding the final RMS voltage and RMS current values. RMS voltage value The calculation formula is: The formula for calculating the effective value of the current IRMS(tk) is: After the square root operation is completed, the output effective voltage and effective current values ​​have standard effective physical dimensions, and their numerical meanings correspond completely to the root mean square definition of AC signals. They can be directly substituted into the subsequent reactive power calculation formula for calculation.

[0103] In another implementation, a half-cycle sliding recursion combined with boundary interpolation compensation is used to solve for the effective values ​​of voltage and current. This method is based on the physical characteristics of the half-cycle root mean square equivalent effective value of a sinusoidal AC signal. It reduces the amount of repetitive computation through a recursive update mechanism, while introducing boundary interpolation and adaptive window length adjustment to improve computational accuracy and adaptability to operating conditions. This method is parallel to the aforementioned first-order low-pass filtering averaging implementation path and can be flexibly selected according to the accuracy requirements and computational constraints of the simulation scenario.

[0104] The specific implementation process proceeds in the following hierarchical manner. The first level is sliding window initialization and register configuration. Half a power frequency cycle is selected as the reference window length for the sliding window, and the number of sampling points contained in the reference window is calculated based on the fixed simulation step size Δt. Independent sliding window buffers and sum-of-squares registers are configured for voltage and current respectively. The buffers are used to store the instantaneous sampled square values ​​within the window in time sequence, and the sum-of-squares register is used to accumulate the sum of the squares of all sampling points within the window. When the data is not full at the beginning of the simulation, the root mean square is calculated based on the number of valid sampling points already stored. After the data fills the complete window, the formal recursive calculation state begins.

[0105] The second level is the recursive update of the sum of squares within the window. For each new instantaneous sample value acquired during the simulation, a square transformation is first performed on it. The resulting square value is then added to the corresponding signal's sum of squares register. Simultaneously, the square value corresponding to the oldest sample point in the current window is removed from the sum of squares register, completing one recursive update of the sliding window. This process requires only two square operations and two addition / subtraction operations, eliminating the need to iterate through all sample points within the window and recalculate. The computational load per step remains constant and does not increase with the window length, making it suitable for high-density iteration requirements with extremely small simulation step sizes.

[0106] The third level is boundary interpolation compensation correction. Since the time boundary of the sliding window cannot always be strictly aligned with the sampling time, ordinary integer sampling point recursion will introduce boundary truncation errors. Therefore, weighted interpolation is introduced for the sampling points at both ends of the window. Based on the time offset ratio between the window boundary and the first and last sampling points, the square values ​​of the sampling points moved out at the beginning and moving in at the end are multiplied by the corresponding time proportion coefficients and then included in the sum of squares. This ensures that the effective integral length of the sliding window is strictly equal to half a power frequency cycle, eliminating the truncation bias caused by sampling discretization and improving the steady-state accuracy of the effective value calculation.

[0107] The fourth level is adaptive window length adjustment. To balance steady-state smoothness and transient response speed, an instantaneous rate of change determination mechanism is introduced to dynamically adjust the effective length of the sliding window. The instantaneous rate of change of adjacent sampling points is calculated in real time. When the rate of change is lower than the preset steady-state threshold, the half-cycle reference window length is maintained to ensure the smoothness of the effective value output. When the rate of change is higher than the preset transient threshold, the effective length of the sliding window is shortened proportionally to reduce the proportion of historical data within the window, so that the effective value can follow the transient changes of the signal amplitude more quickly. After the disturbance subsides and the rate of change falls back to the steady-state range, the window length is gradually restored to the reference length.

[0108] The fifth level is the amplitude restoration operation. The corrected sum of squares within the window is divided by the number of valid sampling points within the window to obtain the mean square. Then, the square root operation is performed on the mean square to obtain the effective voltage and current values ​​at the current moment.

[0109] The computation process of this implementation relies entirely on the recursive calculation of instantaneous sampled values ​​at adjacent time points, resulting in high steady-state calculation accuracy. The tracking response speed under transient conditions can be dynamically adapted through window length adjustment. Compared to the first-order low-pass filter-based RMS calculation, each has its applicable scenarios: the first-order low-pass scheme only needs to store the filter value from the previous time point, resulting in lower storage overhead and making it more suitable for ultra-large-scale multi-loop parallel simulation scenarios; the half-cycle sliding recursive scheme has a higher degree of fit in RMS definition and more flexible adjustment of transient steady-state performance, making it more suitable for simulation analysis scenarios with high amplitude measurement accuracy requirements. The single-step computational power of both schemes is significantly lower than that of the integer-cycle Fourier-type RMS calculation scheme, and both can meet the real-time operation requirements of electromagnetic transient simulation.

[0110] Step 140: Determine the single-phase reactive power of the single-phase circuit under test based on the effective voltage value, the effective current value, and the original phase difference angle.

[0111] The effective values ​​of voltage and current correspond to the magnitude of the electrical quantities in the circuit, respectively. The original phase difference angle corresponds to the phase shift relationship between the voltage and current waveforms. Combining these two types of parameters allows for a complete quantification of the reactive power exchange level of a single-phase circuit. Reactive power is the core basis for analyzing reactive power flow distribution, evaluating load characteristics, and verifying the effectiveness of compensation devices in electromagnetic transient simulations. The calculation process must strictly follow the physical definition of reactive power in AC circuits, while ensuring the accurate correspondence between symbols and reactive power attributes to avoid misjudgment. This step constructs the solution logic based on the phase correlation relationship of single-phase fundamental reactive power. The computational link is simple and can output reactive power results synchronously with each simulation iteration. The specific implementation method is as follows.

[0112] In one implementation, the single-phase reactive power is calculated based on the phase correlation relationship corresponding to the fundamental reactive power, combined with the effective value of voltage, the effective value of current, and the original phase difference angle. The reactive power type of the single-phase circuit under test is determined according to the sign of the original phase difference angle. When the original phase difference angle is positive, the reactive power type of the single-phase circuit under test is inductive reactive power, and when the original phase difference angle is negative, the reactive power type of the single-phase circuit under test is capacitive reactive power.

[0113] Specifically, in a sinusoidal AC circuit, the fundamental reactive power characterizes the scale of periodic energy exchange between the power source and the energy storage elements in the circuit. Its value is equal to the product of the effective voltage value, the effective current value, and the sinusoidal value of the voltage-current phase difference, which is the standard definition of single-phase reactive power. The effective voltage value calculated in step 130 at the current moment... RMS value of current The phase difference angle between the phase difference angle and the phase difference angle after first-order low-pass filtering. By substituting the values, the current sampling time can be obtained. single-phase reactive power The calculation formula is as follows: Using the filtered phase difference angle in the calculation avoids the step-like jumps of the original phase difference from being transmitted to the reactive power output, making the final reactive power value smooth and continuous, which is more convenient for observing the reactive power characteristics under steady-state conditions and analyzing reactive power fluctuations during transient processes.

[0114] The sign of reactive power corresponds one-to-one with the reactive power property of a circuit, and its physical nature is determined by the phase relationship between voltage and current. When When the voltage phase leads the current phase, meaning the current lags behind the voltage, the calculated reactive power is positive, corresponding to inductive reactive power. This indicates that the magnetic field energy exchange of inductive energy storage elements in the tested circuit is dominant. Examples include the reactive power characteristics of inductive loads such as asynchronous motors, power reactors, and transformers. These loads need to absorb reactive power from the system to establish their working magnetic field. When the voltage phase lags behind the current phase, meaning the current leads the voltage, the calculated reactive power is negative, corresponding to capacitive reactive power. This indicates that the electric field energy exchange of capacitive energy storage elements in the measured circuit is dominant. Examples include the reactive power characteristics of components such as parallel capacitors, power cables, and capacitive compensation devices. These components can output reactive power to the system to compensate for reactive power losses caused by inductive loads.

[0115] If the simulation scenario requires a higher reactive power response speed and does not require a strong smoothing effect, the original phase difference angle can be directly substituted into the above formula to complete the reactive power calculation. The calculation method remains the same, and only the smoothness of the output value differs. You can choose flexibly according to the actual simulation requirements.

[0116] In another implementation, a multi-cycle phase integral correction combined with phase fluctuation adaptive domain weighting is used to solve for single-phase reactive power, and the reactive power value and the period-dominant reactive power type identifier are output synchronously.

[0117] The aforementioned single-step instantaneous phase calculation scheme relies solely on phase and amplitude data from a single simulation moment to perform reactive power calculations. Under complex electromagnetic transient simulation conditions characterized by high harmonic content, frequent load switching, and frequent zero-crossing voltage and current transitions, abrupt changes in the discrete phase at a single step can introduce instantaneous calculation errors. Distortions and noise interference at a single sampling point can directly cause instantaneous oscillations in reactive power values, and single-step filtering alone cannot completely eliminate the cumulative measurement deviations over multiple cycles. Therefore, this implementation method abandons the single-step independent calculation mode and establishes a hierarchical correction and calculation architecture. It introduces the average of phase integrals over continuous power frequency cycles to eliminate instantaneous random errors and adds a dynamic compensation mechanism for zero-crossing phase deviations to offset the step distortion caused by phase difference indicator switching. Simultaneously, it allocates nonlinear calculation weights based on the degree of fluctuation in each phase interval, weakening the calculation proportion of periods with severe fluctuations and strengthening the data reference value of stable phase intervals, ultimately achieving a weighted synthesis of high-precision reactive power results. The entire calculation process is implemented using a rolling recursion of timing registers, eliminating the need for large-capacity memory to store full-time voltage and current waveforms. This ensures high-precision calculations while meeting the computational constraints of real-time iteration of microsteps in electromagnetic transient simulation. The complete execution flow consists of six consecutive sub-steps: register initialization, single-step phase domain division and zero-crossing deviation compensation, periodic phase integral accumulation, domain fluctuation variance and adaptive weight solution, reactive power component synthesis and attribute marking, and register rolling update. The specific execution details of each sub-step are as follows.

[0118] Sub-step 1: Domain-Specific Timing Register Initialization. Before the simulation program starts and enters the reactive power measurement loop, multiple sets of independent storage registers are pre-allocated, and all registers are initially set to 0. The register types include two categories: phase integration registers, cycle count registers, zero-crossing deviation smoothing buffer registers, and phase fluctuation temporary storage arrays. Among these, the positive phase integration register... This is used to store the cumulative sum of the product of all positive correction phases and simulation step sizes over N consecutive power frequency cycles; it is also a negative phase integration register. This register stores the cumulative sum of all negative correction phases multiplied by the simulation step size over N consecutive power frequency cycles. N is a customizable cycle length, ranging from 2 to 5 power frequency cycles, and can be configured in advance according to simulation accuracy requirements. Cycle Count Register C nt Used to count the cumulative number of complete power frequency cycles. Zero-crossing deviation smoothing buffer register. This is used to continuously smooth the phase jump difference caused by each voltage and current zero-crossing switch. At the same time, a temporary array of matching length is allocated to temporarily store all corrected phase values ​​within a single statistical period, providing raw data for subsequent fluctuation variance calculation.

[0119] Sub-step 2: Single-step phase domain determination and real-time compensation for zero-crossing phase deviation. After each simulation timing iteration, zero-crossing event monitoring and phase correction operations are performed simultaneously. First, the zero-crossing determination result from step 210 is retrieved. If a voltage or current polarity reversal or a phase difference indicator shift occurs within the current simulation interval, the difference between the filtering phases of the two adjacent steps before and after this zero-crossing is calculated. The global zero-crossing bias cache is updated using a first-order smooth recursive formula: In the formula, α is a preset smoothing forgetting coefficient, fixed at 0.85, which eliminates the interference of a single extreme zero-crossing jump on the global bias through weighted smoothing. After completing the bias update, the current phase difference is subjected to domain-specific correction: if The current phase is determined to be in the positive region corresponding to inductive reactive power, and the phase correction expression is: The corrected phase is multiplied by the current fixed simulation step size Δt and then superimposed and stored in the positive phase integral register. Simultaneously, the corrected phase is written to the phase temporary storage array. If... The current phase is determined to be in the negative region corresponding to capacitive reactive power. The phase correction expression is as follows: Similarly, the integration and array storage are completed. If This indicates that the voltage and current are completely in phase, with no reactive power exchange. No integration or accumulation operation is performed, and the process directly proceeds to the next simulation iteration loop. After each complete power frequency cycle of timing iteration, the cycle counter register C... nt Perform an increment operation when C nt When the value reaches the preset number of statistical cycles N, variance calculation, weighting, and reactive power synthesis are triggered. If less than N complete cycles have been reached, only phase integral accumulation and array storage are continuously executed, and the final reactive power value is not output temporarily.

[0120] Sub-step 3: Solving for the multi-cycle regional average phase. When the cycle counter register meets the statistical cycle threshold, first calculate the average phase of the positive and negative intervals based on the accumulated totals stored in the two sets of integration registers. The standard power frequency duration is denoted as T0, and the total integration duration over N cycles is... The formula for calculating the forward average phase is: The formula for calculating the negative average phase is: The average phase can filter out phase abrupt changes caused by single-step random noise and instantaneous harmonic disturbances, and obtain the steady-state average value of phase shift over N cycles, thus avoiding the continuous error caused by single-step sampling distortion in reactive power calculation.

[0121] Sub-step four: Phase fluctuation variance calculation and nonlinear adaptive weight mapping. Read all corrected phase data from the temporary phase storage array, divide the data into positive and negative phase subsets, and calculate the phase fluctuation variance of the two subsets based on statistical formulas. , The magnitude of variance directly corresponds to the severity of phase jumps, distortions, and noise within a phase interval. A larger variance indicates poorer phase data stability and lower computational value within that interval. An exponential nonlinear mapping function is introduced to convert the variance value into the original weighting coefficients: , In the formula A pre-defined variance adjustment constant, fixed at 10, is used to amplify the effect of variance in suppressing weights, significantly reducing the proportion of drastically fluctuating ranges in the final calculation. After solving the original weights, normalization is performed to obtain the final domain-specific weights. , The sum of the two weights is always equal to 1, ensuring that the numerical scale of the reactive power synthesis process is consistent and that there will be no calculation amplification or attenuation problems.

[0122] Sub-step five: Regional reactive power calculation, global synthesis, and reactive power type labeling. The inductive and capacitive reactive power components within the period are calculated using the regional average phase, with the following formulas: , The cycle-average reactive power is synthesized by combining the normalized adaptive weights, and the synthesis formula is as follows: The synthesized reactive power value is the high-precision average reactive power corresponding to the current N statistical periods. Simultaneously, a reactive power type identifier is generated based on the relationship between the two sets of weights to distinguish the dominant reactive power attribute within a period: when... Setting the flag Flag=1 indicates that inductive reactive power exchange is the dominant force during this statistical period; when Setting the flag to -1 indicates that capacitive reactive power exchange is the dominant force during the statistical period; when Setting the flag to 0 indicates that the scale of inductive and capacitive reactive energy exchange is basically balanced within the period.

[0123] Sub-step six: Register rolling buffer and cyclic reset operation. After completing a set of N-cycle reactive power values ​​and identifier outputs, a rolling update mechanism is executed. The phase integral value corresponding to the last quarter of the current cycle is retained as a historical buffer, while only the remaining majority of the accumulated integral values ​​are cleared. At the same time, the phase temporary storage array is cleared, and the cycle count register C is reset. nt The system resets to zero and restarts the phase integration accumulation cycle for the next set of N consecutive power frequency cycles. This rolling zeroing method retains the effective steady-state phase information of the previous cycle, avoids the discontinuity in the measurement results caused by completely clearing the register, ensures continuous and seamless reactive power output timing, and achieves uninterrupted periodic high-precision reactive power output throughout the simulation.

[0124] This implementation allows for free switching of the computation mode according to simulation observation requirements. If the simulation scenario involves extremely fast transient conditions such as short circuits or faults, and the requirements for measuring response delay are stringent, fixed weights can be directly locked. By disabling the multi-cycle integration and variance weighting modules, the system directly degenerates into a single-step fast reactive power calculation logic. No modification to the entire computational architecture is required; only configuration parameters need to be adjusted to switch between high-precision periodic measurement mode and low-latency single-step measurement mode. Compared to the single-step direct calculation scheme, this implementation significantly reduces measurement errors caused by harmonics, zero-crossing transitions, and transient noise through a multi-layer correction mechanism. Multi-cycle integration averaging eliminates random disturbances, and zero-crossing deviation compensation specifically matches the step transition defects caused by the discrete phase difference identifier in this application. Adaptive domain weighting automatically balances steady-state smoothing capability and transient tracking performance. Furthermore, it uses only a small number of registers to complete the recursive calculations throughout, eliminating the need for large amounts of memory to store multi-cycle original voltage and current waveforms, thus adapting to the computational and memory constraints of large-scale multi-loop parallel electromagnetic transient simulations.

[0125] After completing the numerical calculation of single-phase reactive power, the output unit of reactive power can be standardized and converted according to the actual needs of simulation observation and engineering records, so that the output results can be adapted to circuit measurement scenarios of different magnitudes, which facilitates subsequent data reading, analysis and recording.

[0126] In one implementation, the calculated reactive power is converted into an output value in the required unit according to a set output unit. Pre-configured selectable output unit levels include at least two levels: var and kilovar, which can be flexibly selected according to the capacity of the circuit being measured. Output reactive power The conversion relationships are as follows: Where Q is the original reactive power value calculated in the aforementioned steps. Var is the basic unit of reactive power, corresponding to the voltage unit of volt and the current unit of ampere-hour; kilovar is a commonly used amplification unit in engineering, and the two satisfy the conversion relationship of 1 kilovar equals 1000 var.

[0127] When the output unit is set to var, the original calculation result is output directly. This is suitable for simulation scenarios with small reactive power values, such as small-capacity low-voltage circuits and micro-loads, and can retain more precise decimal places. When the output unit is set to kilovar, the original value is divided by 1000 to complete the order of magnitude conversion. This is suitable for simulation scenarios with large reactive power values, such as medium- and high-voltage power grids and large-capacity loads. This avoids excessive digits in the output value, improving the readability of observations and the convenience of engineering records.

[0128] Unit conversion is performed only in the final output stage and does not affect the intermediate phase discrimination, RMS value calculation, and reactive power solution processes. The entire calculation process maintains a consistent basic dimension, ensuring that the numerical accuracy of the computational link is unaffected by unit conversion. Unit configuration can be set once during simulation initialization or switched as needed during operation to adapt to different engineering observation habits and data output requirements.

[0129] To verify the measurement accuracy, anti-interference ability, and dynamic response performance of the method in this application under different working conditions, the following description is provided in conjunction with the accompanying drawings and specific simulation test examples.

[0130] This test case uses the following... Figure 3 The test circuit shown uses a single-phase controlled current source as excitation and an external resistive-capacitive grounded load to form a single-phase electrical circuit. The load parameters are set to resistance R = 1Ω and capacitance C = 100μF, making the circuit resistive-capacitive to simulate common loads in actual power grids. The simulation step size is fixed at Δt = 50μs, the fundamental frequency f = 60Hz, the fundamental amplitude A = 2, the initial phase φ = 0°, and the simulation duration is 1s. In this embodiment, the filtering time constant is set to T = 0.02s, and the reactive power unit is Var. Three sets of tests were conducted to examine the performance of the method under harmonic interference, non-sinusoidal waveforms, and amplitude abrupt changes. The test reference signal was in cosine form.

[0131] During the test, the single-phase controlled current source signal is divided into two stages: from t=0s to 0.5s, the signal is a standard sine wave i(t)=2sin(2π·60t); at t=0.5s, the signal condition changes, and the waveform after the change is maintained until the end of the simulation. The three sets of tests correspond to different signal forms after the change, as detailed below.

[0132] Test 1 is a fundamental frequency superimposed with the third harmonic condition, used to verify the harmonic suppression capability of the method. After t=0.5s, the control signal of the controlled current source is set as follows: This involves superimposing a third harmonic with an amplitude of 0.2 and a frequency of 180Hz onto the fundamental frequency. The simulation process records the comparison data between the instantaneous reactive power measured by this method and the theoretical instantaneous reactive power throughout the entire simulation run. Figure 4 A waveform comparison chart of the measurement results and theoretical values ​​is provided. Figure 5 This is the corresponding power error curve. From... Figure 4 and Figure 5 As can be seen, despite the presence of third harmonic interference in the signal, the reactive power measured by the method of this application (measured value) basically coincides with the true value, and the transient and steady-state errors are both less than 0.001. This indicates that the method has good harmonic suppression capability and can accurately extract the fundamental reactive power without the need for additional filtering.

[0133] Test 2 is a fundamental frequency superimposed with a sawtooth wave distortion condition, used to verify the robustness of the method under severely distorted non-sinusoidal waveforms. After t=0.5s, the control signal of the controlled current source is set to a fundamental frequency superimposed with a sawtooth wave. The sawtooth wave parameters are: frequency 60Hz, duty cycle 0.5, peak-to-peak value 1, and initial phase 90°. The specific expression is: Where 0.5·sawtooth(·,0.5) represents a symmetrical sawtooth wave with a peak-to-peak value of 1 and a duty cycle of 0.5. This control signal contains rich harmonic components and has a high degree of waveform distortion. Figure 6 The distorted current waveform is shown. Figure 7 The waveforms showing the reactive power measured by the method of this application are compared with the theoretical reactive power. Because the error between the measured value and the theoretical true value is extremely low, Figure 7 The two inner waveform curves approximately overlap. Figure 8 The corresponding power error curve is shown. The results show that even under conditions of severe waveform distortion, the method of this application can still accurately track reactive power changes, with errors of less than 0.001 in both transient and steady-state conditions, proving the robustness of this method in measuring reactive power of non-sinusoidal waveforms.

[0134] Test 3 is a fundamental amplitude abrupt change condition, used to examine the dynamic response speed of the method in this application during amplitude abrupt changes. Before t=0.5s, the control signal of the controlled current source is a fundamental sine wave; at t=0.5s, the current amplitude abruptly changes from 2 to 4, and the piecewise expression of the signal is: . Figure 9 The waveforms showing the comparison between the reactive power measured by the method of this application and the theoretical reactive power are shown. This is because the error between the measured value and the theoretical true value is extremely small. Figure 9 The two waveform curves in the middle approximately overlap. Figure 10 The corresponding power error curve is shown in the figure. As can be seen from the figure, at the instant of a sudden change in amplitude, the reactive power measured by the method of this application has almost no delay and can immediately track the new reactive power level. The errors in both transient and steady-state conditions are less than 0.001. This fully demonstrates the fast dynamic response characteristics of this method, which does not require a sliding data window and uses open-loop recursive calculation. Its response performance is superior to traditional reactive power measurement methods based on phase-locked loops or Fourier transforms.

[0135] The above three sets of test results jointly verify the single-phase reactive power determination method proposed in this application. It has good performance in terms of steady-state calculation accuracy, harmonic interference suppression, distortion waveform adaptability and transient response speed, and can meet the real-time reactive power calculation requirements in electromagnetic transient simulation scenarios.

[0136] The aforementioned steps enable real-time calculation of the single-phase reactive power of the tested single-phase circuit. This real-time output of single-phase reactive power can serve as the core feedback parameter for the control of the single-phase static var compensator within the electromagnetic transient simulation. In existing electromagnetic transient simulation systems, the control logic for reactive power compensation equipment relies on closed-loop regulation based on the reactive power values ​​output by the integer-cycle Fourier transform. Constrained by the integer-cycle data window, there is naturally an output delay of one power frequency cycle. In transient simulation scenarios such as short-circuit faults, large-capacity load switching, and load operation with harmonic distortion, the control commands lag behind the actual electrical state of the circuit, easily leading to technical defects such as compensation overshoot, undercompensation, excessive operating overvoltage, and mismatch between the simulated waveform and the actual on-site operating characteristics. At the same time, traditional calculation methods are prone to misjudging the inductive and capacitive reactive power attributes due to waveform distortion interference, resulting in incorrect switching directions of the compensation branches. To address the aforementioned technical deficiencies, this application provides a single-phase static var compensating control method based on the aforementioned single-phase reactive power determination results. This method fully reuses the phase difference, zero-crossing characteristics, simulation step size, and filter-related intermediate parameters generated synchronously during the calculation process, eliminating the need for additional independent calculation modules for voltage zero-crossing detection and waveform distortion identification. It balances steady-state smoothness with rapid response to transient disturbances. Specifically, the method includes the following steps:

[0137] Step 1110: Obtain the single-phase reactive power and associated intermediate characteristic parameters of the single-phase circuit under test.

[0138] After each iteration of the electromagnetic transient simulation timeline, the single-phase reactive power corresponding to the current simulation moment is output synchronously according to the single-phase reactive power solution process fully described above. Simultaneously, two types of intermediate parameters are retained: the cross-time zero-crossing change characteristics obtained during the phase discrimination process and the filtered phase difference angle. The cross-time zero-crossing change characteristics include indicators of whether the voltage and current polarity reverses in adjacent sampling moments, and the filtered phase difference angle is used to distinguish between inductive and capacitive reactive power types. The entire numerical and characteristic parameter generation timeline is completely synchronized with the simulation iteration timeline, eliminating output lag caused by multi-cycle data caching. The logic for obtaining each parameter and the filtering operation method have been fully explained above and will not be repeated here.

[0139] Step 1120: Calculate the reactive power change rate based on the single-phase reactive power of continuous iteration steps, and adaptively divide the circuit operation conditions by combining the zero-crossing change characteristics.

[0140] First, the single-phase reactive power output from two adjacent simulation iteration steps is used to perform a difference calculation, and the formula for calculating the reactive power change rate is defined: In the formula, This represents the single-phase reactive power at the second sampling time. This represents the single-phase reactive power corresponding to the previous adjacent sampling time. A fixed simulation step size is used for electromagnetic transient simulation.

[0141] Retrieve the zero-crossing characteristics of the voltage and current synchronous output in step 1110, count the total number of zero-crossing reversals within the set time period, and calculate the zero-crossing deviation coefficient. Configure a fixed steady-state rate threshold. Transient rate threshold The two types of thresholds are adaptively corrected using a zero-crossing deviation coefficient. The correction formula is as follows: , If the rate of change of reactive power The tested single-phase circuit is determined to be in steady-state operation. If the reactive power change rate... The system determines that the tested single-phase circuit is under transient disturbance conditions such as fault or sudden load change. When the rate is between the two correction thresholds, the condition determination result of the previous iteration is used.

[0142] Traditional operating condition identification uses a fixed threshold. Waveform distortion continuously triggers frequent zero-crossings of voltage and current, causing small, persistent fluctuations in reactive power. The fixed threshold also easily leads to frequent switching between steady-state and transient modes, causing compensation equipment to repeatedly switch on and off. This solution reuses the original cross-time zero-crossing variation characteristics to generate a zero-crossing deviation coefficient. The more severe the waveform distortion, the more adaptively the threshold is widened, suppressing misjudgments of operating conditions caused by distortion. Existing discrimination results are reused throughout the process, eliminating the need for additional harmonic analysis calculations.

[0143] Step 1130: Perform differentiated compensation capacity adjustment calculations for steady-state and transient operating conditions respectively.

[0144] Under steady-state operation, the reactive power deviation and zero-crossing timing trigger the staged branch switching. First, calculate the reactive power deviation of the circuit: In the formula, The target reactive power value is preset for simulation; the switching dead zone threshold is adaptively generated by combining the zero-crossing deviation coefficient. , This is the basic dead zone amplitude.

[0145] when At that time, the current compensation access capacity will remain unchanged. At that time, retrieve the voltage zero-crossing change characteristics obtained in step 1110, and wait for the next voltage zero-crossing interval before outputting the switching command.

[0146] The rated reactive power of a single-level compensated branch is denoted as The formula for rounding down a series of tangents: The type of branch to be switched is determined based on the sign of the filtered phase difference angle: a positive filtered phase difference angle indicates that the circuit is inductive and should be switched to a capacitor branch; a negative filtered phase difference angle indicates that the circuit is capacitive and should be switched to a reactance branch.

[0147] Traditional compensation control requires a separate zero-crossing detection algorithm, and the detection timing is offset from the reactive power calculation timing. Inaccurate zero-crossing switching timing can easily generate simulation operation overvoltage. This solution directly reuses the original cross-time zero-crossing change characteristics of the phase detection stage. The timing of calculation, zero-crossing identification and control are completely consistent, eliminating the simulation distortion caused by timing misalignment. Steady-state zero-crossing switching can significantly reduce transient impact voltage.

[0148] Under transient disturbance conditions, the single-step stepless regulation is calculated based on reactive power deviation and reactive power change rate. Instead of waiting for the voltage to cross zero, a proportional-derivative control model is directly constructed to calculate the single-step compensation regulation under transient disturbance conditions. In the formula, This is the proportional adjustment coefficient. The differential adjustment coefficient increases linearly with the rate of change of reactive power. The more severe the disturbance, the higher the differential weight, thus enhancing the rapid tracking capability.

[0149] The calculated adjustment amount is directly superimposed on the equivalent reactive capacity of the current compensation equipment, and the equivalent reactance and equivalent capacitance parameters of the compensation branch in the simulation model are modified in real time. Each simulation iteration step can complete a capacity fine-tuning.

[0150] Traditional Fourier calculation methods require at least one power frequency cycle to update reactive power feedback, making it impossible to achieve continuous stepless adjustment with micro-steps. This method can output reactive power synchronously from adjacent dual sampling points, and its time-delay characteristic supports closed-loop fine-tuning in each simulation step, significantly reducing the compensation time for transient reactive power gaps and suppressing instantaneous voltage drops and overshoot.

[0151] Step 1140: Issue capacity adjustment instructions to the single-phase static var compensator module in the simulation to form a closed-loop iterative process.

[0152] The hierarchical branch switching command or stepless capacity correction parameter is synchronously sent to the single-phase static var compensator module inside the electromagnetic transient simulation model to complete the update of the equivalent reactive power parameter; jump to step 1110 to re-acquire the instantaneous sampling values ​​of voltage and current at the next set of adjacent sampling times and solve the single-phase reactive power to continuously complete the closed-loop control iteration.

[0153] The entire control process reuses existing parameters such as instantaneous sampling polarity, zero-crossing markers across time intervals, filtered phase difference, and simulation step size generated during the single-phase reactive power determination process. No new independent signal acquisition, distortion detection, or phase recognition logic is required, significantly reducing memory usage and single-step computational overhead. Compared to traditional compensation control schemes relying on whole-cycle Fourier reactive power, this method compresses the feedback delay from one power frequency cycle to a simulation microstep size. The number of erroneous switching operations of compensation branches under distorted loads decreases by more than 90%, and simulation stuttering and computation timeout issues do not occur in large-scale multi-loop electromagnetic transient parallel simulation scenarios.

[0154] It is understood that, in order to achieve the functions in the above embodiments, the computer device includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and method steps described in conjunction with the embodiments disclosed in this application, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application scenario and design constraints of the technical solution.

[0155] Furthermore, as a response to the above Figure 1 The implementation of the method embodiment shown in this application provides a single-phase reactive power determination device. The embodiment of this device corresponds to the foregoing method embodiments. For ease of reading, this embodiment will not repeat the details of the foregoing method embodiments one by one, but it should be clear that the device in this embodiment can correspondingly implement all the contents of the foregoing method embodiments. Specifically, as shown... Figure 12 As shown, the single-phase reactive power determination device 1200 includes:

[0156] The acquisition module 1210 is used to acquire the instantaneous voltage and current sampling values ​​of the single-phase circuit under test in the electromagnetic transient simulation model at the first sampling time and the second sampling time. The first sampling time and the second sampling time are adjacent sampling times, and the first sampling time is before the second sampling time.

[0157] The first determining module 1220 is used to determine the original phase difference angle between the voltage and current of the single-phase circuit under test based on the polarity relationship of the instantaneous voltage sample value and the zero-crossing change characteristics across time.

[0158] The second determining module 1230 is used to determine the effective value of the voltage of the single-phase circuit under test based on the instantaneous voltage sampling value, and to determine the effective value of the current of the single-phase circuit under test based on the instantaneous current sampling value.

[0159] The third determining module 1240 is used to determine the single-phase reactive power of the single-phase circuit under test based on the effective value of voltage, the effective value of current, and the original phase difference angle.

[0160] Furthermore, such as Figure 12 As shown, the first determining module 1220 is specifically used to determine the phase difference identifier between the voltage and current of the single-phase circuit under test based on the polarity relationship of the instantaneous voltage sampling value and the zero-crossing change characteristics across time intervals; and to determine the original phase difference angle between the voltage and current of the single-phase circuit under test based on the phase difference identifier.

[0161] Furthermore, such as Figure 12As shown, the first determining module 1220 is specifically used to set the phase difference identifier to a first identifier state when the instantaneous voltage sample value and the instantaneous current sample value have the same polarity at the same sampling time; to set the phase difference identifier to a second identifier state when the instantaneous current sample value undergoes a polarity reversal or reaches a zero-crossing state between the first sampling time and the second sampling time; and to set the phase difference identifier to a third identifier state when the instantaneous voltage sample value undergoes a polarity reversal or reaches a zero-crossing state between the first sampling time and the second sampling time.

[0162] Furthermore, such as Figure 12 As shown, the first determining module 1220 is specifically used to multiply the preset reference angle with the phase difference identifier to obtain the original phase difference angle between the voltage and current of the single-phase circuit under test.

[0163] Furthermore, such as Figure 12 As shown, the second determining module 1230 is specifically used to determine the first filtering coefficient based on the simulation step size and the filtering time constant; to perform square transformation on the instantaneous voltage sample value and the instantaneous current sample value respectively to obtain the square voltage value and the square current value; to perform time-series iterative filtering on the square voltage value and the square current value respectively based on the first filtering coefficient to obtain the average voltage value and the average current value; and to perform amplitude restoration calculation on the average voltage value and the average current value respectively to obtain the effective voltage value and the effective current value.

[0164] Furthermore, such as Figure 12 As shown, the third determining module 1240 is specifically used to calculate the single-phase reactive power based on the phase correlation relationship corresponding to the fundamental reactive power, combined with the effective value of voltage, the effective value of current, and the original phase difference angle; and to determine the reactive power type of the single-phase circuit under test according to the sign of the original phase difference angle. When the original phase difference angle is positive, the reactive power type of the single-phase circuit under test is inductive reactive power, and when the original phase difference angle is negative, the reactive power type of the single-phase circuit under test is capacitive reactive power.

[0165] Furthermore, such as Figure 12 As shown, the first determining module 1220 is also used to determine the second filtering coefficient based on the simulation step size and the filtering time constant; and to perform time-weighted filtering on the original phase difference angle based on the second filtering coefficient to obtain the filtered phase difference angle.

[0166] Optionally, the single-phase reactive power determination device may be an electronic device with data processing capabilities, or a functional module in the electronic device, and there is no limitation thereto.

[0167] For example, the electronic device can be a server, which can be a single server or a server cluster consisting of multiple servers. As another example, the electronic device can be a mobile phone, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, as well as cellular phones, personal digital assistants (PDAs), augmented reality (AR) devices, virtual reality (VR) devices, and other terminal devices. As yet another example, the electronic device can also be a recording device, video surveillance equipment, etc. This application does not impose any special limitations on the specific form of the electronic device.

[0168] The following example uses an electronic device to determine single-phase reactive power. Figure 13 As shown, Figure 13 The hardware structure of an electronic device 1300 provided in this application.

[0169] like Figure 13 As shown, the electronic device 1300 includes a processor 1310, a communication line 1320, and a communication interface 1330.

[0170] Optionally, the electronic device 1300 may also include a memory 1340. The processor 1310, the memory 1340, and the communication interface 1330 can be connected via a communication line 1320.

[0171] The processor 1310 can be a central processing unit (CPU), a network processor (NP), a digital signal processor (DSP), a microprocessor, a microcontroller, a programmable logic device (PLD), or any combination thereof. The processor 1310 can also be any other device with processing capabilities, such as a circuit, device, or software module, without limitation.

[0172] In one example, processor 1310 may include one or more CPUs, for example Figure 13 CPU0 and CPU1 in the CPU.

[0173] As an optional implementation, electronic device 1300 may include multiple processors, for example, in addition to processor 1310, it may also include processor 1370. Communication line 1320 is used to transmit information between the components included in electronic device 1300.

[0174] Communication interface 1330 is used for communication with other devices or other communication networks. These other communication networks can be Ethernet, Radio Access Network (RAN), Wireless Local Area Networks (WLAN), etc. Communication interface 1330 can be a module, circuit, transceiver, or any device capable of enabling communication.

[0175] Memory 1340 is used to store instructions. These instructions can be computer programs.

[0176] The memory 1340 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and / or instructions; it may also be a random access memory (RAM) or other type of dynamic storage device capable of storing information and / or instructions; it may also be an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, or other magnetic storage devices, etc., without limitation.

[0177] It should be noted that the memory 1340 can exist independently of the processor 1310, or it can be integrated with the processor 1310. The memory 1340 can be used to store instructions, program code, or some data, etc. The memory 1340 can be located inside or outside the electronic device 1300, without restriction.

[0178] Processor 1310 is configured to execute instructions stored in memory 1340 to implement the communication method provided in the following embodiments of this application. For example, when electronic device 1300 is a terminal or a chip in a terminal, processor 1310 can execute instructions stored in memory 1340 to implement the steps performed by the sending end in the following embodiments of this application.

[0179] As an optional implementation, the electronic device 1300 also includes an output device 1350 and an input device 1360. The output device 1350 can be a display screen, speaker, or other device capable of outputting data from the electronic device 1300 to the user. The input device 1360 can be a keyboard, mouse, microphone, joystick, or other device capable of inputting data into the electronic device 1300.

[0180] It should be pointed out that, Figure 13 The structure shown does not constitute a limitation on the electronic device, except... Figure 13 In addition to the components shown, the electronic device may include more or fewer components than illustrated, or combine certain components, or have different component arrangements.

[0181] The single-phase reactive power determination device and application scenarios described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the evolution of single-phase reactive power determination devices and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.

[0182] This application provides a storage medium storing a program that, when executed by a processor, implements the single-phase reactive power determination method.

[0183] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0184] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0185] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A method for determining single-phase reactive power, characterized in that, The method includes: The instantaneous voltage and current sampling values ​​of the single-phase circuit under test in the electromagnetic transient simulation model are obtained at the first sampling time and the second sampling time. The first sampling time and the second sampling time are adjacent sampling times, and the first sampling time is before the second sampling time. The original phase difference angle between the voltage and current of the measured single-phase circuit is determined based on the polarity relationship of the instantaneous voltage sample value and the instantaneous current sample value and the zero-crossing change characteristics across time intervals. The effective value of the voltage of the single-phase circuit under test is determined based on the instantaneous voltage sampling value, and the effective value of the current of the single-phase circuit under test is determined based on the instantaneous current sampling value. The single-phase reactive power of the measured single-phase circuit is determined based on the effective value of the voltage, the effective value of the current, and the original phase difference angle.

2. The method according to claim 1, characterized in that, The original phase difference angle between the voltage and current of the measured single-phase circuit is determined based on the polarity relationship of the instantaneous voltage sample value and the instantaneous current sample value, and the zero-crossing change characteristics across time intervals. This includes: The phase difference identifier between the voltage and current of the measured single-phase circuit is determined based on the polarity relationship between the instantaneous voltage sample value and the instantaneous current sample value, as well as the zero-crossing change characteristics across time intervals. The original phase difference angle between the voltage and current of the single-phase circuit under test is determined based on the phase difference identifier.

3. The method according to claim 2, characterized in that, The phase difference identifier between the voltage and current of the measured single-phase circuit is determined based on the polarity relationship of the instantaneous voltage sample value and the instantaneous current sample value, and the zero-crossing change characteristics across time intervals. This includes: When the instantaneous voltage sample value and the instantaneous current sample value have the same polarity at the same sampling moment, the phase difference identifier is set to the first identifier state; When the instantaneous current sample value undergoes a polarity reversal or reaches a zero-crossing state between the first sampling time and the second sampling time, the phase difference identifier is set to the second identifier state; When the instantaneous voltage sample value undergoes a polarity reversal or reaches a zero-crossing state between the first sampling time and the second sampling time, the phase difference indicator is set to the third indicator state.

4. The method according to claim 2, characterized in that, Determining the original phase difference angle between the voltage and current of the measured single-phase circuit based on the phase difference identifier includes: Multiply the preset reference angle by the phase difference indicator to obtain the original phase difference angle between the voltage and current of the single-phase circuit under test.

5. The method according to claim 1, characterized in that, Determining the effective voltage value of the single-phase circuit under test based on the instantaneous voltage sampling value, and determining the effective current value of the single-phase circuit under test based on the instantaneous current sampling value, includes: The first filter coefficient is determined based on the simulation step size and the filter time constant. The instantaneous voltage sample value and the instantaneous current sample value are squared respectively to obtain the squared voltage value and the squared current value; Based on the first filtering coefficient, the squared voltage value and the squared current value are subjected to time-series iterative filtering to obtain the average voltage value and the average current value. The average voltage and the average current are respectively subjected to amplitude restoration calculation to obtain the effective voltage value and the effective current value.

6. The method according to claim 1, characterized in that, The single-phase reactive power of the measured single-phase circuit is determined based on the effective voltage value, the effective current value, and the original phase difference angle. The single-phase reactive power includes both numerical value and type, including: Based on the phase correlation relationship corresponding to the fundamental reactive power, and combined with the effective value of the voltage, the effective value of the current, and the original phase difference angle, the value of the single-phase reactive power is calculated. The reactive power type of the single-phase circuit under test is determined based on the sign of the original phase difference angle. When the original phase difference angle is positive, the reactive power type of the single-phase circuit under test is inductive reactive power, and when the original phase difference angle is negative, the reactive power type of the single-phase circuit under test is capacitive reactive power.

7. The method according to claim 2 or 4, characterized in that, After determining the original phase difference angle between the voltage and current of the single-phase circuit under test based on the phase difference identifier, the method further includes: The second filter coefficient is determined based on the simulation step size and the filter time constant; The original phase difference angle is subjected to time-weighted filtering based on the second filtering coefficient to obtain the filtered phase difference angle.

8. A single-phase reactive power determination device, characterized in that, The device includes: The acquisition module is used to acquire the instantaneous voltage and current sampling values ​​of the single-phase circuit under test in the electromagnetic transient simulation model at the first sampling time and the second sampling time. The first sampling time and the second sampling time are adjacent sampling times, and the first sampling time is before the second sampling time. The first determining module is used to determine the original phase difference angle between the voltage and current of the measured single-phase circuit based on the polarity relationship between the instantaneous voltage sample value and the instantaneous current sample value and the zero-crossing change characteristics across time intervals; The second determining module is used to determine the effective value of the voltage of the single-phase circuit under test based on the instantaneous voltage sampling value, and to determine the effective value of the current of the single-phase circuit under test based on the instantaneous current sampling value. The third determining module is used to determine the single-phase reactive power of the measured single-phase circuit based on the effective voltage value, the effective current value, and the original phase difference angle.

9. A storage medium, characterized in that, The storage medium includes a stored program, wherein, when the program is executed, it controls the device containing the storage medium to perform the single-phase reactive power determination method as described in any one of claims 1-7.

10. An electronic device, characterized in that, The device includes at least one processor, at least one memory connected to the processor, and a bus; wherein the processor and the memory communicate with each other through the bus; the processor is used to call program instructions in the memory to execute the single-phase reactive power determination method as described in any one of claims 1-7.