A method, system, device and medium for adaptive setting of control parameters of a grid-forming inverter

By using an adaptive tuning method based on deep reinforcement learning agents, the virtual inertia and damping parameters of the grid-type inverter are optimized, solving the problem of insufficient response and stability under multiple operating conditions in the existing technology, and realizing the coordinated optimization of frequency dynamics and stability margin.

CN123163097APending Publication Date: 2026-11-24GUIZHOU POWER GRID CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611469766.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-21
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

In existing technologies, the virtual inertia and damping parameters of grid-connected inverters are difficult to balance fast response and stability margin when the grid strength and power operating point change, resulting in low accuracy of the overall adaptability of control parameters under multiple operating conditions.

Method used

A deep reinforcement learning agent is used to perform collaborative adaptive tuning of virtual inertia, virtual damping, and virtual impedance parameters under a unified framework. By constructing a closed-loop tuning process involving training environment, reward function iteration, and continuous motion quantity mapping, the adaptability of control parameters is optimized.

Benefits of technology

It achieves coordinated optimization of frequency dynamics and small-signal stability margin of grid-connected inverters under multiple operating conditions, avoids abnormal responses caused by control parameters going out of bounds, and improves the adaptive output accuracy of control parameters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123163097A_ABST
    Figure CN123163097A_ABST
Patent Text Reader

Abstract

This invention discloses an adaptive tuning method, system, device, and medium for grid-connected inverter control parameters, belonging to the technical field of grid-connected inverter parameter tuning. The method includes the following steps: constructing a training environment for a grid-connected inverter controlled by a virtual synchronous generator; collecting the state variables of the grid-connected inverter during operation in the training environment; constructing a reward function, and evaluating the continuous action quantities output by the deep reinforcement learning agent during training rounds using the reward function, iteratively updating the deep reinforcement learning agent based on the evaluation results; and, based on the updated deep reinforcement learning agent, outputting continuous action quantities according to the state variables, mapping the continuous action quantities to physical constraints, and applying them to the outer active frequency control stage in the virtual synchronous generator control. This invention, through a closed-loop tuning process involving the construction of a training environment, reward function iteration, and continuous action quantity mapping, can improve the accuracy of adaptive output of control parameters under multiple operating conditions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of parameter tuning technology for grid-connected inverters, specifically to an adaptive tuning method, system, device, and medium for control parameters of a grid-connected inverter. Background Technology

[0002] With the large-scale grid connection of new energy power generation, the power system exhibits a high proportion of power electronics, significantly weakening the mechanical inertia and damping support of traditional synchronous generators. Grid-connected inverters, as key devices actively supporting grid voltage and frequency, often employ virtual synchronous generator control to simulate the external characteristics of synchronous motors. The virtual inertia and damping parameters of the virtual synchronous generator control directly affect the system's frequency response and power dynamics, and their equivalent impedance characteristics change with variations in grid strength and power operating point. Therefore, to meet the comprehensive performance optimization requirements of grid-connected inverters under varying operating conditions, adaptive tuning of the virtual synchronous generator control parameters and output impedance-related parameters is necessary to improve the coordinated adaptability of system dynamic response and stability margin.

[0003] In existing technologies, VSG-type grid inverters often employ fixed virtual inertia and damping parameters, or adjust them in segments based on simple rules such as frequency deviation and rate of change. Some also utilize traditional intelligent algorithms for offline optimization. These methods typically only focus on time-domain frequency and power dynamics, and the adjustment rules rely on simplified empirical models. This makes it difficult to balance fast response and stability margin when grid strength and power point change, resulting in low overall adaptability and accuracy of control parameters under multiple operating conditions. Summary of the Invention

[0004] In view of the above-mentioned problems, the present invention provides a method, system, device and medium for adaptive tuning of control parameters of grid-type inverter.

[0005] Therefore, the technical problem solved by this invention is: how to use a deep reinforcement learning agent to perform collaborative adaptive tuning of virtual inertia, virtual damping and virtual impedance parameters under a unified framework, so as to achieve collaborative optimization of frequency dynamics, active power recovery and small signal stability margin of grid-connected inverters under the conditions of changing grid strength and power operating point.

[0006] To address the aforementioned technical problems, this invention provides the following technical solution: an adaptive tuning method for control parameters of a grid-connected inverter, comprising the following steps: constructing a training environment for a grid-connected inverter controlled by a virtual synchronous generator; collecting the state variables of the grid-connected inverter during operation in the training environment; constructing a reward function, and in each training round, evaluating the continuous action quantities output by the deep reinforcement learning agent using the reward function, and iteratively updating the deep reinforcement learning agent based on the evaluation results; based on the updated deep reinforcement learning agent, outputting continuous action quantities according to the state variables, mapping the continuous action quantities to a preset physical constraint range, and applying them to the outer active frequency control link in the virtual synchronous generator control.

[0007] As a preferred embodiment of the adaptive tuning method for control parameters of a grid-connected inverter according to the present invention, the steps of constructing the training environment include: building a basic simulation model of the grid-connected inverter; generating different operating conditions by configuring the grid equivalent impedance and active power reference values ​​in the basic simulation model to obtain a multi-condition simulation model; constructing a phase margin calculation module based on the impedance interaction characteristics between the equivalent admittance on the grid-connected inverter side and the equivalent admittance on the grid side; and connecting the phase margin calculation module to the multi-condition simulation model to establish a data interaction link to obtain the training environment.

[0008] As a preferred embodiment of the adaptive tuning method for control parameters of a grid-type inverter according to the present invention, the step of acquiring the state variables includes: acquiring the time-domain dynamic response of the grid-type inverter during operation in the training environment; performing impedance interaction analysis between the equivalent admittance on the grid-type inverter side and the equivalent admittance on the grid side to calculate the phase margin; and using the time-domain dynamic response and the phase margin together as the state variables of the deep reinforcement learning agent.

[0009] As a preferred embodiment of the adaptive tuning method for control parameters of a grid-type inverter according to the present invention, the step of constructing the reward function includes: constructing a set of time-domain penalty terms; comparing the phase margin with a preset stability margin threshold in segments to obtain the comparison result; generating a stability margin penalty term based on the comparison result and a preset weight parameter; and adding the values ​​of each item in the set of time-domain penalty terms to the value of the stability margin penalty term to obtain the reward function.

[0010] As a preferred embodiment of the adaptive tuning method for control parameters of a grid-type inverter according to the present invention, the evaluation step includes: performing response constraint analysis on the time-domain dynamic response quantity using the time-domain penalty term set to obtain a response penalty result; substituting the target margin corresponding to the control parameters determined by the continuous action quantity into the stability margin penalty term to obtain a stability margin penalty result; generating an instantaneous reward value for the continuous action quantity based on the response penalty result and the stability margin penalty result; and determining the evaluation result based on the instantaneous reward value and the state quantity at the next moment.

[0011] As a preferred embodiment of the adaptive tuning method for control parameters of a network-type inverter according to the present invention, the iterative update step includes: combining current state variables, continuous action variables, and corresponding evaluation results into an experience sample and storing it in the experience replay pool of the deep reinforcement learning agent; responding to the number of experience samples reaching a preset training threshold, randomly selecting multiple sets of interaction samples from the experience replay pool, calculating a temporal difference objective based on the multiple sets of interaction samples, using the temporal difference objective to update the parameters of the action value network in the deep reinforcement learning agent, and obtaining an updated action value network; using the action value gradient information output by the updated action value network to optimize the policy network of the deep reinforcement learning agent, and obtaining an optimized policy network; performing soft parameter updates on the target networks corresponding to the updated action value network and the optimized policy network, respectively, to obtain an updated deep reinforcement learning agent.

[0012] As a preferred embodiment of the adaptive tuning method for control parameters of a grid-connected inverter according to the present invention, the step of mapping the continuous action quantity to a preset physical constraint range includes: identifying the control parameter type corresponding to the continuous action quantity; determining the physical constraint boundary corresponding to the preset physical constraint range based on the control parameter type; scaling the continuous action quantity using the physical constraint boundary to obtain an initial tuning value limited to the physical constraint range; querying the parameter change rate limit value corresponding to the control parameter type based on the initial tuning value; using the target tuning value of the previous control cycle as a comparison benchmark, calculating the parameter change amount between the initial tuning value and the comparison benchmark; limiting the parameter change amount using the parameter change rate limit value to obtain the target tuning value; and outputting the target tuning value as the result of mapping the continuous action quantity to the physical constraint range.

[0013] This invention provides an adaptive tuning system for control parameters of a grid-type inverter.

[0014] To solve the above-mentioned technical problems, the present invention provides the following technical solution: an adaptive tuning system for control parameters of a grid-connected inverter, comprising: The training environment construction module is used to build a training environment for a grid-connected inverter controlled by a virtual synchronous generator; The state quantity acquisition module is used to acquire the state quantities of the grid-type inverter during operation in the training environment; The agent update module is used to construct a reward function. In each training round, the reward function is used to evaluate the continuous action output of the deep reinforcement learning agent, and the deep reinforcement learning agent is iteratively updated based on the evaluation results. The control parameter tuning module is used to output continuous action quantities based on the updated deep reinforcement learning agent according to the state quantity, map the continuous action quantities to a preset physical constraint range, and act on the outer active frequency control link in the virtual synchronous generator control.

[0015] The present invention provides a computer device, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the adaptive tuning method for control parameters of a grid-type inverter.

[0016] The present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the adaptive tuning method for control parameters of a grid-type inverter.

[0017] The beneficial effects of this invention are: This invention achieves adaptive tuning of control parameters, avoids abnormal responses caused by control parameters going out of bounds, and gets rid of dependence on human experience or fixed rules by using deep reinforcement learning agents.

[0018] This invention improves the accuracy of adaptive output of control parameters under multiple operating conditions by constructing a closed-loop tuning process of training environment, reward function iteration and continuous motion quantity mapping. Attached Figure Description

[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 The above is a flowchart of an adaptive tuning method for control parameters of a grid-type inverter provided in one embodiment of the present invention.

[0021] Figure 2This is a flowchart illustrating the state variable acquisition process of an adaptive tuning method for control parameters of a grid-type inverter, as provided in one embodiment of the present invention.

[0022] Figure 3 The flowchart illustrates an iterative update deep reinforcement learning agent for an adaptive tuning method of control parameters for a grid-type inverter, as provided in one embodiment of the present invention. Detailed Implementation

[0023] To make the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of the present invention.

[0024] Example 1, referring to Figure 1 This is one embodiment of the present invention, which provides an adaptive tuning method for control parameters of a grid-connected inverter, comprising the following steps: Construct a training environment for a grid-connected inverter controlled by a virtual synchronous generator; Collect the state variables of the grid-type inverter during its operation in the training environment; Construct a reward function, and in each training round, use the reward function to evaluate the continuous action output of the deep reinforcement learning agent, and iteratively update the deep reinforcement learning agent based on the evaluation results; Based on the updated deep reinforcement learning agent, continuous action quantities are output according to the state variables, and the continuous action quantities are mapped to a preset physical constraint range, which are then applied to the outer active frequency control link in the virtual synchronous generator control.

[0025] VSG-type grid-connected inverters often employ fixed virtual inertia and damping parameters, or adjust them in segments based on simple rules such as frequency deviation and rate of change. Some also utilize traditional intelligent algorithms for offline optimization. These methods typically focus only on time-domain frequency and power dynamics, and the adjustment rules rely on simplified empirical models. They struggle to balance rapid response and stability margin when grid strength and power point change, resulting in low overall adaptability and accuracy of control parameters under multiple operating conditions.

[0026] This invention improves the accuracy of adaptive output of control parameters under multiple operating conditions by constructing a closed-loop tuning process of training environment, reward function iteration and continuous motion quantity mapping.

[0027] Example 2, refer to Figures 1-3 As an embodiment of the present invention, an adaptive tuning method for control parameters of a grid-connected inverter is provided based on the previous embodiment, comprising the following steps: S1. Construct a training environment for a grid-type inverter controlled by a virtual synchronous generator.

[0028] In one embodiment of this invention, the grid-type inverter controlled by the virtual synchronous generator is a power electronic conversion device that simulates the inertia and damping characteristics of a synchronous generator through a control algorithm. It can actively establish the AC side voltage amplitude and phase angle, effectively functioning as a controlled voltage source, and possesses voltage and frequency support capabilities. The device includes a DC side power supply, a three-phase voltage source inverter, filters, line impedance, a power grid or load, and a control system. The control system includes an outer active power frequency control loop, an outer voltage reference generation loop, and an inner voltage and current control loop. Control parameters include at least virtual inertia and virtual damping. The outer active power frequency control loop simulates the operating characteristics of the synchronous generator through virtual inertia and virtual damping. Virtual inertia primarily affects the frequency change rate and response speed, while virtual damping primarily affects oscillation attenuation and power recovery processes.

[0029] In one embodiment of this example, the training environment serves as an interactive platform for the deep reinforcement learning agent during the learning process of control parameter tuning strategies. It is used to receive the control parameters output by the deep reinforcement learning agent, update the operating state of the grid-type inverter, calculate and return the next-time state quantity and the instantaneous reward value to the deep reinforcement learning agent.

[0030] In one embodiment of this invention, the deep reinforcement learning agent is a neural network decision-making unit capable of continuous action output and interactive learning with a grid-connected inverter training environment controlled by a virtual synchronous generator. The deep reinforcement learning agent includes a policy network layer, a value network layer, an experience replay storage unit, and a target network layer. The policy network layer is located in the action output path of the deep reinforcement learning agent, and the value network layer is located in the reward evaluation path. Both the policy network layer and the value network layer employ deep neural network structures. In an embodiment employing a deep deterministic policy gradient algorithm, the policy network layer is an Actor network, and the action-value network layer is a Critic network. The Actor network directly outputs the values ​​of virtual inertia and virtual damping based on the state variables. The Critic network evaluates the long-term cumulative reward of the current parameter combination based on the state variables, continuous action variables, and immediate reward values. The experience replay pool stores training samples composed of state variables, continuous action variables, and immediate reward values. The target network layer is used to improve the stability of the deep reinforcement learning agent's training process.

[0031] The steps for constructing the training environment include S1.1 to S1.4: S1.1 Build the basic simulation model of the grid-type inverter.

[0032] The basic simulation model of the grid-type inverter is built by constructing the electrical topology of the main circuit, constructing the control logic of the control system, and establishing the signal interaction link between the main circuit and the control system.

[0033] The process of constructing the main circuit electrical topology involves configuring the electrical component parameters of the DC power supply, three-phase voltage source inverter, filter, line impedance, AC grid or local load, arranging the power transmission connection sequence of each electrical component, establishing the current flow path between each electrical component, and forming a main circuit structure that can realize the conversion and transmission of DC power to AC power.

[0034] The process of constructing the control logic of the control system involves establishing the operational rules for the outer active power frequency control loop, the outer voltage reference generation loop, and the inner voltage and current control loop, respectively. The outer active power frequency control loop constructs the operational relationship between active power and frequency based on virtual inertia parameters and virtual damping parameters. The mathematical expression corresponding to this operational relationship is as follows: In the formula, For virtual inertia, This is the virtual damping coefficient. The rated angular frequency, The output angular frequency of the grid-connected inverter. This is a reference value for active power. This refers to the actual output active power of the grid-connected inverter. The outer active frequency control circuit generates angular frequency and phase angle reference signals based on the difference between the active power reference value and the actual output active power. The outer voltage reference generation circuit generates a voltage amplitude reference signal in conjunction with the reactive power control logic. The inner voltage and current control circuit establishes outer voltage regulation logic and inner current regulation logic, performs closed-loop tracking calculations on the voltage and current reference signals, and generates pulse modulation drive signals.

[0035] The process of establishing the signal interaction link between the main circuit and the control system involves transmitting the output voltage signal, output current signal, output active power signal, and output reactive power signal acquired by the main circuit to the corresponding input ports of the control system, and transmitting the pulse modulation drive signal output by the control system to the drive input port of the three-phase voltage source inverter, thus forming a workable closed-loop simulation structure.

[0036] In this embodiment, the main circuit parameters of the basic simulation model of the grid-type inverter controlled by the virtual synchronous generator are set as follows: DC power supply voltage 800V, rated power of the three-phase voltage source inverter 100kW, filter inductance 1.5mH, filter capacitor 200μF, line equivalent resistance 0.1Ω, AC grid rated line voltage 380V, and rated frequency 50Hz; the initial control parameters of the control system are set as the initial value of the virtual inertia 0.2kg·m. 2Virtual damping initial value 10 N·m·s / rad, rated angular frequency The initial active power reference value is 70kW, with a speed of 314 rad / s. The outer active power frequency control loop substitutes these initial parameters into the mathematical expression corresponding to the relationship between active power and frequency. The actual output active power of the grid-connected inverter under operating conditions Equal to the active power reference value of 70kW, the output angular frequency of the grid-connected inverter Equal to the rated angular frequency of 314 rad / s, the values ​​on both sides of the equation are balanced, generating a stable angular frequency and phase angle reference signal; the inner layer voltage and current control loop tracks the voltage reference signal to generate a pulse modulation drive signal, driving the three-phase voltage source inverter to output a stable three-phase AC voltage and current, completing the basic simulation model construction of the grid-type inverter with closed-loop operation.

[0037] S1.2 In the basic simulation model, different operating conditions are generated by configuring the equivalent impedance of the power grid and the reference value of active power, thus obtaining a multi-condition simulation model.

[0038] Within the structural framework of the basic simulation model, the operations of configuring the equivalent impedance of the power grid, configuring the active power reference value, generating different operating conditions, and obtaining a multi-condition simulation model are implemented layer by layer through parameter value modification, combination of operating scenarios, and embedding of operating condition switching logic.

[0039] The operation of configuring the equivalent impedance of the power grid involves modifying the equivalent inductance or equivalent impedance parameter values ​​on the power grid side in the basic simulation model. Multiple sets of equivalent impedance parameters of different sizes are set, with different parameters corresponding to different power grid operating conditions. Setting a smaller value for the equivalent inductance of the power grid corresponds to a strong power grid scenario, while setting a larger value corresponds to a weak power grid scenario, thereby simulating the operating environment of varying power grid strength.

[0040] The operation of configuring active power reference values ​​modifies the active power reference values ​​of the outer active frequency control loop in the basic simulation model. Multiple sets of active power reference value parameters with different values ​​are set, and different values ​​correspond to different power operating points. Smaller active power reference values ​​correspond to light load operating point scenarios, and larger active power reference values ​​correspond to heavy load operating point scenarios, thereby simulating the operating environment with changing power operating points.

[0041] Multiple sets of equivalent impedance parameters of the power grid are paired with multiple sets of active power reference parameters. Each parameter pair corresponds to an independent operating condition, covering various combinations of different grid strengths and power operating points. The operating conditions corresponding to all parameter pairs are written into the operating condition calling logic of the basic simulation model, enabling the basic simulation model to switch to the operating state corresponding to any set of parameter pairs according to preset rules, forming a multi-condition simulation model that supports switching between multiple operating conditions.

[0042] In this embodiment, operating condition configuration is carried out based on the basic simulation model built in step S1.1. Two sets of equivalent grid inductance parameters are set: the first set of equivalent grid inductance parameters is 0.5mH, corresponding to a strong grid scenario, and the second set of equivalent grid inductance parameters is 3mH, corresponding to a weak grid scenario. Two sets of active power reference values ​​are set: the first set of active power reference values ​​is 30kW, corresponding to a light load operating point scenario, and the second set of active power reference values ​​is 100kW, corresponding to a heavy load operating point scenario. The two sets of equivalent grid inductance parameters and the two sets of active power reference values ​​are paired to obtain four operating conditions: strong grid light load, strong grid heavy load, weak grid light load, and weak grid heavy load. The four operating conditions are written into the operating condition calling logic of the basic simulation model, so that the basic simulation model can switch to the operating state corresponding to any set of parameters according to a preset sequence, resulting in a multi-condition simulation model covering various grid strengths and power operating points.

[0043] S1.3. Based on the impedance interaction characteristics between the equivalent admittance on the grid-connected inverter side and the equivalent admittance on the grid side, a phase margin calculation module is constructed.

[0044] The phase margin calculation module is constructed by establishing admittance interaction operation rules, performing frequency scanning logic, establishing amplitude and phase feature identification rules, establishing phase margin solution rules, and encapsulating independent calculation units.

[0045] The process of establishing the admittance interaction calculation rules involves combining the main circuit parameter dimensions, control link parameter dimensions, operating point parameter dimensions of the grid-connected inverter, and the equivalent impedance parameter dimensions of the grid to establish impedance interaction relationship calculation rules for the parallel interaction between the equivalent admittance on the grid-connected inverter side and the equivalent admittance on the grid side. The impedance interaction relationship calculation rules can receive specific input parameter values ​​and generate admittance calculation expressions under corresponding operating conditions, which are used to characterize the impedance interaction characteristics between the grid-connected inverter and the grid.

[0046] The process of performing frequency scanning logic involves defining a fixed, finite frequency scanning range and frequency step size, setting traversal operation rules for substituting admittance calculation expressions point by point, and sequentially outputting the amplitude and phase data corresponding to each frequency point. The process of establishing amplitude and phase feature identification rules involves setting operation rules for generating amplitude-frequency response curves based on amplitude data from all frequency points and generating phase-frequency response curves based on phase data from all frequency points, and setting judgment rules for identifying anti-resonance characteristic frequency points of the amplitude-frequency response curve and locating the corresponding phase change segments of the phase-frequency response curve. The process of establishing phase margin solution rules involves setting operation rules for drawing asymptotes of the phase curve near the anti-resonance characteristic frequency point and calculating the angle between the asymptotes and the vertical reference line, and setting a mapping rule for using the angle value as the phase margin. The phase margin is used to characterize the stability margin of the grid-type inverter from the small-signal instability boundary. The process of encapsulating an independent calculation unit involves encapsulating all the operational logic of equivalent admittance calculation, frequency scanning, feature identification, and phase margin calculation into an independent phase margin calculation module, reserving parameter input ports and phase margin value output ports.

[0047] In this embodiment, a phase margin calculation module is constructed based on the parameter dimensions of the multi-condition simulation model obtained in step S1.2. The input parameter ports of the phase margin calculation module correspond one-to-one with the configurable parameters of the multi-condition simulation model in step S1.2. It reads the 0.5mH equivalent inductance of a strong grid, the 3mH equivalent inductance of a weak grid, and the reference values ​​of 30kW light-load active power and 100kW heavy-load active power configured in step S1.2, which can cover the parameter inputs of four operating conditions: strong grid light load, strong grid heavy load, weak grid light load, and weak grid heavy load. The phase margin calculation module internally presets the impedance interaction relationship calculation rules of the equivalent admittance on the grid-type inverter side and the equivalent admittance on the grid side in parallel, presets the frequency scanning logic of a finite frequency band with a scanning range of 10Hz to 1000Hz and a step size of 1Hz, and presets the phase margin solution rules for anti-resonance feature identification and phase curve asymptote angle calculation. The output port of the phase margin calculation module can output the phase margin under the corresponding operating conditions, thus completing the phase margin calculation module with callable calculation capabilities.

[0048] S1.4 Connect the phase margin calculation module to the multi-condition simulation model, establish a data interaction link, and obtain the training environment.

[0049] A unified data transmission format is defined, and the main circuit parameter nodes of the grid-type inverter, the equivalent impedance parameter nodes of the grid, the active power reference value parameter nodes, and the virtual inertia and virtual damping control parameter nodes in the multi-condition simulation model are connected to the parameter input ports of the phase margin calculation module through data mapping, so that the phase margin calculation module can obtain all input parameters under the current operating condition in real time.

[0050] Define a unified numerical feedback format, connect the phase margin output port of the phase margin calculation module to the state quantity acquisition node of the multi-condition simulation model, so that the phase margin can be incorporated into the state acquisition system of the multi-condition simulation model as a state feedback quantity.

[0051] A trigger signal output terminal is set at the operating condition switching node of the multi-operating condition simulation model, and a trigger signal receiving terminal is set at the calculation start terminal of the phase margin calculation module. The multi-operating condition simulation model outputs a trigger signal while completing the operating condition switching, triggering the phase margin calculation module to start the phase margin calculation process under the current operating condition, ensuring that the phase margin calculation result matches the current operating condition one by one.

[0052] The multi-condition simulation model after accessing the phase margin calculation module is integrated into a training environment. The training environment has the ability to receive control parameters and actions of the deep reinforcement learning agent, update the system operating state, and output interactive states including phase margin and real-time reward values.

[0053] In this embodiment, the phase margin calculation module constructed in step S1.3 is connected to the multi-condition simulation model obtained in step S1.2. When configuring the parameter output link, the grid parameter nodes (0.5mH equivalent inductance of a strong grid, 3mH equivalent inductance of a weak grid), the power parameter nodes (30kW light load active power reference value, 100kW heavy load active power reference value), and the control parameter nodes (virtual inertia, virtual damping) in the multi-condition simulation model are connected to the parameter input port of the phase margin calculation module through a unified data format. This allows the phase margin calculation module to directly read all input parameters for the four operating conditions: strong grid light load, strong grid heavy load, weak grid light load, and weak grid heavy load. When configuring the result feedback link, the phase margin output port of the phase margin calculation module is connected to the state quantity acquisition node of the multi-condition simulation model, so that the phase margin can be used together with the frequency deviation, frequency change rate, and active power deviation as state feedback quantities. When configuring the synchronous triggering logic for operating conditions, it is set that every time the multi-operating condition simulation model switches to a new set of operating conditions, a synchronous trigger signal is sent to the phase margin calculation module, triggering the phase margin calculation module to perform the phase margin calculation for the corresponding operating condition. After completing the construction of all links, a training environment is obtained that can provide a multi-operating condition operating environment, output state variables including phase margin, and receive control parameter actions.

[0054] In another optional implementation of this embodiment, the grid-connected inverter controlled by the virtual synchronous generator can further incorporate a virtual impedance compensation stage in the control system. This stage is positioned between the outer voltage reference generation stage and the inner voltage and current control stage. It corrects and compensates the voltage reference value through output current feedback, enabling the inverter's external ports to exhibit adjustable equivalent output impedance characteristics. The virtual impedance parameters include virtual resistance and virtual reactance. The compensated voltage reference is obtained by subtracting the product of the virtual impedance and the inverter's output current from the original voltage reference generated by the outer voltage reference generation stage. While retaining the basic structure of the outer active power frequency control and the core adjustment parameters of virtual inertia and virtual damping, the virtual impedance compensation stage further improves the impedance interaction relationship and phase margin through equivalent output impedance shaping, enabling the grid-connected inverter to achieve coordinated adjustment among frequency dynamics, active power recovery, impedance stability margin, and voltage support capability.

[0055] S2. Collect the state variables of the grid-type inverter during its operation in the training environment.

[0056] In one embodiment of this example, the state variables are a combination of physical quantities used to characterize the system operating state and stability margin of the grid-type inverter controlled by the virtual synchronous generator during the training environment operation. The state variables may include frequency deviation, frequency change rate, active power deviation, and phase margin obtained based on impedance analysis, which are used to enable the deep reinforcement learning agent to output corresponding control parameters according to the current system operating state.

[0057] Frequency deviation is the difference between the output angular frequency and the rated angular frequency, used to characterize the degree to which the system frequency deviates from the rated operating value. For example, when the system experiences load fluctuations or power command changes, the frequency deviation value can increase. Frequency change rate is the rate of change of angular frequency over time, used to characterize the speed of frequency change. For example, the frequency change rate can be large in the initial stage of a transient process. Active power deviation is the difference between the active power reference value and the actual output active power of the grid-connected inverter, used to characterize the degree of power recovery. For example, when the active power reference value undergoes a step change, the active power deviation value can initially increase and then gradually converge. Phase margin is a frequency domain stability margin index obtained based on the impedance interaction relationship between the equivalent admittance on the grid-connected inverter side and the equivalent admittance on the grid side. It is used to characterize the stability margin of the grid-connected inverter from the small-signal instability boundary under the current operating point and current control parameters. For example, a positive phase margin indicates that the current operating point has a certain small-signal stability margin, while a phase margin close to zero or negative indicates that the system is approaching or entering the small-signal instability risk region.

[0058] Reference Figure 2 As shown, the steps for acquiring the state variables include S2.1 to S2.3: S2.1 Collect the time-domain dynamic response of the grid-type inverter during its operation in the training environment.

[0059] The basic simulation model of the grid-type inverter built in step S1.1 is used to acquire real-time operating data at the sampling time and perform difference calculation and rate of change calculation to realize the acquisition of time-domain dynamic response.

[0060] The basic simulation model of the grid-type inverter in the training environment outputs the output angular frequency and the actual output active power of the grid-type inverter at the current sampling time. The training environment provides the active power reference value and rated angular frequency under the current operating conditions.

[0061] Frequency deviation is obtained by calculating the difference between the output angular frequency and the rated angular frequency. The expression for frequency deviation calculation is as follows: ,in For frequency deviation, For the output angular frequency, The rated angular frequency is used to characterize the degree to which the system frequency deviates from the rated operating value; the frequency change rate is obtained by differentiating the output angular frequency over time, and is used to characterize how quickly the angular frequency changes over time; the active power deviation is obtained by calculating the difference between the active power reference value and the actual output active power of the grid-connected inverter, and the expression for the active power deviation is: ,in For active power deviation, This is a reference value for active power. The actual output active power, and the active power deviation is used to characterize the degree of power recovery.

[0062] Frequency deviation, rate of change of frequency, and active power deviation together constitute the acquired time-domain dynamic response. The time-domain dynamic response can be normalized before being input into the neural network of the deep reinforcement learning agent. Normalization is achieved by mapping the values ​​of each time-domain dynamic response to a preset range, thereby eliminating the impact of dimensional and numerical range differences between the various time-domain dynamic responses on the stability of deep reinforcement learning training.

[0063] In this embodiment, the operating condition corresponding to the current sampling time is set as the heavy load condition of the power grid configured in step S1.2, i.e., the equivalent inductance of the power grid is 0.5mH and the active power reference value is 100kW. The rated angular frequency is 314rad / s. At the current sampling time, the output angular frequency output by the basic simulation model of the grid-type inverter controlled by the virtual synchronous generator is 312.5rad / s, and the actual output active power is 85kW. The frequency deviation is obtained by subtracting 314rad / s from 312.5rad / s, resulting in a frequency deviation of -1.5rad / s. The active power deviation is obtained by subtracting 85kW from 100kW, resulting in an active power deviation of 15kW. The frequency change rate is obtained by differentiating the output angular frequency versus time curve at the current sampling time, resulting in a frequency change rate of 0.8rad / s. 2 Normalization processing resulted in a frequency deviation of -1.5 rad / s and a frequency change rate of 0.8 rad / s. 2 The active power deviation of 15kW is mapped to a numerical range of -1 to 1, and the mapped values ​​together constitute the normalized time-domain dynamic response quantity as a component of the state input of the deep reinforcement learning agent.

[0064] S2.2. The phase margin is calculated by analyzing the impedance interaction relationship between the equivalent admittance on the grid-type inverter side and the equivalent admittance on the grid side.

[0065] Impedance interaction analysis is performed by establishing impedance interaction based on the equivalent admittance expression of the grid-type inverter side and the equivalent admittance expression of the grid side, and then performing frequency scanning on the relevant admittance expressions within a limited frequency band.

[0066] The equivalent admittance on the grid-connected inverter side is derived from the control parameters and main circuit parameters of the grid-connected inverter. This equivalent admittance reflects the admittance characteristics of the inverter output port at different frequencies. The equivalent admittance on the grid side is derived from the grid equivalent impedance and grid equivalent inductance. This equivalent admittance reflects the admittance characteristics of the grid connection port at different frequencies.

[0067] Impedance interaction is established based on the equivalent admittance on the inverter side and the equivalent admittance on the grid side, reflecting the impedance interaction characteristics between the inverter and the grid. Frequency scanning is achieved by calculating the equivalent admittance on the grid-connected inverter side and the equivalent admittance on the grid side point by point within a preset frequency range. Frequency scanning obtains the amplitude-frequency characteristic curves and phase-frequency characteristic curves of the equivalent admittance on the grid-connected inverter side, as well as the amplitude-frequency characteristic curves and phase-frequency characteristic curves of the equivalent admittance on the grid side. The amplitude-frequency characteristic curve reflects the law of admittance amplitude changing with frequency, and the phase-frequency characteristic curve reflects the law of admittance phase changing with frequency.

[0068] Phase margin is calculated by identifying the anti-resonance characteristic frequency point in the amplitude-frequency curve and measuring the angle between the phase curve asymptote and the vertical reference line near the anti-resonance characteristic frequency point. The anti-resonance characteristic is manifested as a dip in amplitude in the amplitude-frequency curve near a certain frequency. The phase curve asymptote is the tangent or fitted straight line of the phase-frequency curve near the anti-resonance characteristic frequency point. The vertical reference line is the phase baseline corresponding to a phase of -180 degrees. The phase margin is equal to the angle between the phase curve asymptote and the vertical reference line. A positive phase margin indicates a certain small-signal stability margin at the current operating point; a phase margin close to zero or negative indicates that the system is approaching or entering a small-signal instability risk region. The phase margin is not directly calculated from the transient waveform; it characterizes the frequency domain stability margin under the current operating point and current control parameters.

[0069] In this embodiment, based on the virtual synchronous generator control of the grid-type inverter in step S2.2, which operates under heavy load conditions of a strong power grid (i.e., rated angular frequency 314 rad / s, output angular frequency 312.5 rad / s, active power reference value 100 kW, and actual output active power 85 kW), the equivalent admittance expression on the grid-type inverter side is derived from the initial virtual inertia value of 0.2 kg·m. 2 The initial virtual damping value of 10 N·m·s / rad is derived from the main circuit parameters. The equivalent admittance expression on the grid side is derived from the equivalent grid inductance of 0.5 mH and the equivalent grid resistance of 0.1 Ω. Frequency scanning is performed within a finite frequency band from 10 Hz to 1000 Hz, calculating the equivalent admittance on the inverter side and the grid side point by point with a step size of 1 Hz. This yields the amplitude-frequency characteristic curves and phase-frequency characteristic curves for both the inverter side and the grid side. When the amplitude-frequency curve shows an amplitude dip near a certain frequency (i.e., anti-resonance characteristic) and the phase-frequency curve shows a significant phase change, the corresponding frequency point value for the anti-resonance characteristic is recorded. Near the anti-resonance characteristic frequency point, read the phase value of the phase frequency curve, draw the asymptote of the phase curve, and measure the angle between the asymptote of the phase curve and the negative 180-degree vertical reference line. The angle is the phase margin. The measured phase margin is 15 degrees. A positive phase margin indicates that the current operating point has a small signal stability margin of 15 degrees.

[0070] S2.3. The time-domain dynamic response and the phase margin are used together as the state variables of the deep reinforcement learning agent.

[0071] The state variables are constructed by concatenating the time-domain dynamic response and phase margin in a preset order. The time-domain dynamic response includes frequency deviation, rate of change of frequency, and active power deviation. The phase margin is calculated through impedance interaction analysis. The state variables are represented as a vector by arranging the frequency deviation, rate of change of frequency, active power deviation, and phase margin in a preset order. The state variables can be expressed as follows: ,in for Angular frequency deviation at time, for The rate of change of frequency or angular frequency at any given time. for Active power deviation at any given time, for The phase margin is obtained based on impedance analysis at each moment. State variables serve as the state inputs to the deep reinforcement learning agent, enabling the agent to output corresponding control parameters based on the current system operating state.

[0072] In this embodiment, according to steps S2.1 and S2.2, the time-domain dynamic response includes a frequency deviation of -1.5 rad / s and a frequency change rate of 0.8 rad / s. 2 The active power deviation is 15kW and the phase margin is 15 degrees. State quantities are expressed as a frequency deviation of -1.5 rad / s and a frequency change rate of 0.8 rad / s. 2 The active power deviation of 15kW and the phase margin of 15 degrees are arranged in the order of frequency deviation, rate of change of frequency, active power deviation, and phase margin to form a four-element vector, i.e., st=[-1.5,0.8,15,15]. The state variables are input to the policy network of the deep reinforcement learning agent, and the policy network outputs virtual inertia and virtual damping based on the state variables.

[0073] In another optional implementation of this embodiment, the state variables can also be a combination of frequency deviation, frequency change rate, active power deviation, phase margin obtained based on impedance analysis, and equivalent voltage droop caused by virtual impedance compensation. The equivalent voltage droop can be the influence of virtual impedance compensation on the voltage reference value. The equivalent voltage droop can be used to characterize the degree of voltage reference attenuation caused by virtual impedance compensation. For example, when the values ​​of virtual resistance and virtual reactance are too large, the value of equivalent voltage droop can increase, thereby leading to a decrease in voltage support capability. After the equivalent voltage droop is added to the state space, the deep reinforcement learning agent can consider the voltage reference compensation amplitude constraint when adjusting the virtual impedance parameters.

[0074] S3. Construct a reward function. In each training round, use the reward function to evaluate the continuous action output of the deep reinforcement learning agent, and iteratively update the deep reinforcement learning agent based on the evaluation results.

[0075] In one embodiment of this invention, the reward function is a comprehensive evaluation function composed of a frequency deviation penalty term, a frequency change rate penalty term, an active power deviation penalty term, and a stability margin penalty term. For example, in the initial transient phase of a grid-connected inverter system controlled by a virtual synchronous generator, when the frequency deviation, frequency change rate, and active power deviation are all large, the penalty values ​​corresponding to the frequency deviation penalty term, frequency change rate penalty term, and active power deviation penalty term are also large. The deep reinforcement learning agent dynamically adjusts the virtual inertia and virtual damping based on the evaluation results of the reward function to reduce the frequency deviation, constrain the frequency change rate, and promote active power recovery. At the same time, the stability margin penalty term ensures that the combination of virtual inertia and virtual damping parameters selected by the deep reinforcement learning agent does not cause the phase margin to fall below the lower limit of the stability margin.

[0076] The steps for constructing the reward function include S3.1 to S3.3: S3.1 Construct a set of time-domain penalty terms.

[0077] The construction of the time-domain penalty term set is achieved by calculating the penalty value corresponding to each state variable during the operation of the grid-type inverter controlled by the virtual synchronous generator and summarizing the penalty values ​​into a set.

[0078] The penalty values ​​corresponding to each state variable are calculated by generating a frequency deviation penalty term using a negative penalty form for frequency deviation. The negative penalty form means that the penalty value is negative; the larger the frequency deviation, the smaller the penalty value, to guide the deep reinforcement learning agent in selecting control parameters that reduce frequency deviation. Similarly, a frequency change rate penalty term is generated by applying a negative penalty form to frequency change rate; the larger the frequency change rate, the smaller the penalty value, to guide the deep reinforcement learning agent in selecting control parameters that reduce frequency change rate. Likewise, an active power deviation penalty term is generated by applying a negative penalty form to active power deviation; the larger the active power deviation, the smaller the penalty value, to guide the deep reinforcement learning agent in selecting control parameters that reduce active power deviation. All penalty values ​​are then aggregated into a set, completing the construction of the time-domain penalty term set.

[0079] In this embodiment, the time-domain dynamic response acquired in step S2.1 is used as the basis for normalization processing. The frequency deviation of -1.5 rad / s is normalized and mapped to the range of -1 to 1 to obtain a normalized frequency deviation of -0.3 and a frequency change rate of 0.8 rad / s. 2After normalization mapping to the range of -1 to 1, the normalized frequency change rate is 0.4. The active power deviation of 15kW, after normalization mapping to the range of -1 to 1, is 0.6. A frequency deviation penalty term is generated by applying a negative penalty to the normalized frequency deviation of -0.3, resulting in a frequency deviation penalty term of -0.3; a frequency change rate penalty term is generated by applying a negative penalty to the normalized frequency change rate of 0.4, resulting in a frequency change rate penalty term of -0.4; and an active power deviation penalty term is generated by applying a negative penalty to the normalized active power deviation of 0.6, resulting in an active power deviation penalty term of -0.6. The frequency deviation penalty term -0.3, the frequency change rate penalty term -0.4, and the active power deviation penalty term -0.6 are summarized into a set of time-domain penalty term data, resulting in a time-domain penalty term set.

[0080] S3.2. The phase margin is compared with the preset stability margin threshold in segments to obtain the comparison result. Based on the comparison result, a stability margin penalty term is generated in combination with the preset weight parameters.

[0081] The segmented comparison operation obtains the phase margin and a preset stability margin threshold, compares the phase margin with the preset stability margin threshold, and determines the range of the phase margin based on the comparison result. The phase margin is obtained through impedance analysis based on the impedance interaction relationship between the equivalent admittance on the inverter side and the equivalent admittance on the grid side. Specifically, it involves frequency scanning of the equivalent admittance expressions on the inverter side and the grid side within a limited frequency band to obtain the amplitude-frequency response curve and the phase-frequency response curve. The phase margin is determined based on the angle between the asymptote of the phase curve and the vertical reference line near the anti-resonance characteristic frequency point of the amplitude-frequency curve. The segmented comparison compares the phase margin with the preset stability margin threshold. If the phase margin is less than the preset stability margin threshold, the comparison result indicates that the phase margin is in the range below the stability margin requirement; if the phase margin is greater than or equal to the preset stability margin threshold, the comparison result indicates that the phase margin is in the range that meets the stability margin requirement.

[0082] The stability margin penalty term generation operation calculates the stability margin penalty term by selecting the preset weight parameters corresponding to the comparison results based on the comparison results and combining the difference between the phase margin and the preset stability margin threshold.

[0083] The stability margin penalty term employs a piecewise penalty calculation rule. When the phase margin is less than a preset stability margin threshold, When the phase margin is greater than or equal to the preset stability margin threshold, .in for Phase margin at time, To establish a stability margin threshold, For the penalty weight parameter, For reward weight parameters, and That is, preset weight parameters, The penalty calculation for the corresponding phase margin being lower than the stability margin requirement range. The reward calculation corresponds to the phase margin meeting the stability margin requirement range. When the comparison result shows that the phase margin is below the stability margin requirement range, the following applies: Weight calculation, Taking a negative value is the penalty value; the lower the phase margin is than the preset stability margin threshold, the more severe the penalty. and The larger the difference, the larger the negative magnitude of the stability margin penalty term, i.e., the heavier the penalty. When the comparison result shows that the phase margin is within the range that meets the stability margin requirements, the following is adopted: Weight calculation, A positive value is the reward value; the higher the phase margin is than the preset stability margin threshold, the greater the reward. and The larger the difference, the larger the positive amplitude of the stability margin penalty term, which means more reward.

[0084] In this embodiment, based on the phase margin calculation result in step S2.2, the phase margin is 15 degrees. A preset stability margin threshold is set. The degree is 10, and the preset weighting parameters are... Take 0.5, Set the phase margin to 0.2. The value 15 and the preset stability margin threshold Compare the numerical values ​​of 10, and consider the phase margin. The value 15 is greater than the preset stability margin threshold. A value of 10 indicates that the phase margin falls within the stability margin requirement range. Based on the comparison results, the weights corresponding to the stability margin requirement range are selected. Substitute into the piecewise function formula Calculation, i.e. =0.2×(15-10)=1.0, so the stability margin penalty term is 1.0.

[0085] S3.3 Add the values ​​of each item in the time-domain penalty term set to the value of the stability margin penalty term to obtain the reward function.

[0086] The training environment for a grid-connected inverter controlled by a virtual synchronous generator reads the values ​​of frequency deviation penalty, frequency change rate penalty, and active power deviation penalty from the time-domain penalty term set, and reads the value of stability margin penalty. The frequency deviation penalty, frequency change rate penalty, active power deviation penalty, and stability margin penalty are then subjected to arithmetic addition, and the result of the arithmetic addition is returned to the deep reinforcement learning agent as an immediate reward value.

[0087] The reward function is expressed as ,in for The reward function at time step, for Frequency deviation penalty term at time, for The penalty term for the rate of change of frequency at time. for Active power deviation penalty term at any given time. for Stability margin penalty at any given moment.

[0088] The reward function is used to evaluate the quality of the combination of control parameters output by the deep reinforcement learning agent in the current state. The larger the reward function value, the better the current control parameter combination, and the smaller the reward function value, the worse the current control parameter combination. This guides the deep reinforcement learning agent to learn parameter adjustment strategies that maximize the reward function value.

[0089] In this embodiment, based on the time-domain penalty term set constructed in step S3.1 and the stability margin penalty term generated in step S3.2, the frequency deviation penalty term in the time-domain penalty term set is -0.3, the frequency change rate penalty term is -0.4, the active power deviation penalty term is -0.6, and the stability margin penalty term is 1.0. An arithmetic addition operation is performed on the frequency deviation penalty term -0.3, the frequency change rate penalty term -0.6, the active power deviation penalty term -0.6, and the stability margin penalty term 1.0, i.e. =-0.3+(-0.4)+(-0.6)+1.0=-0.3, so the reward function value is -0.3. The training environment of the grid-type inverter controlled by the virtual synchronous generator returns the reward function value -0.3 as the immediate reward value to the deep reinforcement learning agent.

[0090] In another optional implementation of this embodiment, the reward function may also introduce a virtual impedance parameter, that is, the reward function may also include a virtual voltage drop penalty term. The virtual voltage drop penalty term may be a penalty term used to limit the adverse effects of virtual impedance compensation on the voltage reference value. The virtual voltage drop penalty term is usually based on the virtual voltage drop amplitude caused by virtual impedance, so as to avoid the virtual resistance parameter and virtual reactance parameter being too large, which would weaken the voltage reference or reduce the voltage support capability.

[0091] In one embodiment of this invention, the continuous action quantities are the virtual inertia and virtual damping directly output by the deep reinforcement learning agent at each sampling moment. Both virtual inertia and virtual damping are continuously changing physical quantities. Both virtual inertia and virtual damping act on the outer active power frequency control loop of the grid-connected inverter controlled by the virtual synchronous generator. Virtual inertia mainly affects the frequency change rate and system response speed, while virtual damping mainly affects the oscillation decay process and active power recovery process. For example, when the frequency deviation and frequency change rate are large, the deep reinforcement learning agent can output a large virtual inertia to suppress the frequency change rate and a large virtual damping to accelerate power oscillation decay. As it gradually enters a steady state, the virtual inertia and virtual damping output by the deep reinforcement learning agent tend to level off.

[0092] The steps for evaluating the continuous action quantities output by the deep reinforcement learning agent include S3.4 to S3.6: S3.4. Use the set of time-domain penalty terms to perform response constraint analysis on the time-domain dynamic response quantity to obtain the response penalty result.

[0093] After scaling or limiting the virtual inertia and virtual damping contained in the continuous motion quantity and mapping them to a preset physical constraint range, the virtual active frequency control loop of the grid-type inverter controlled by the virtual synchronous generator is input and the operation parameters of the outer active frequency control loop are updated. This drives the grid-type inverter in the training environment to run and output three types of time-domain dynamic response quantities: frequency deviation, frequency change rate, and active power deviation. Then, the preset negative penalty calculation rules of the time-domain penalty term set are read, and the frequency deviation, frequency change rate, and active power deviation are substituted into the frequency deviation penalty term calculation rules, respectively, to calculate the three independent penalty values. Finally, the three penalty values ​​are arithmetically summed to obtain the response penalty result corresponding to the continuous motion quantity.

[0094] Scaling or limiting processing restricts the range of virtual inertia and virtual damping by setting upper and lower threshold values ​​of parameters, thus preventing abnormal system response caused by parameters going out of bounds. The negative penalty calculation rule adopts a negative mapping logic where the larger the deviation value, the smaller the penalty value, so that the larger the deviation of the time domain response, the heavier the penalty, thereby constraining and guiding the dynamic performance of continuous motion in the time domain.

[0095] In this embodiment, based on the training environment of a high-voltage power grid under heavy load, the continuous action output of the deep reinforcement learning agent includes a virtual inertia of 0.3 kg·m. 2 The virtual damping is 15 N·m·s / rad. After the parameters are confirmed to be valid through a preset range limit check, the virtual inertia is set to 0.3 kg·m. 2Substitute the virtual damping of 15 N·m·s / rad into the calculation expression of the outer active frequency control loop in step S1.1. After updating the operational parameters of the outer active power frequency control loop, the grid-type inverter is driven to run. The time-domain dynamic response at the current sampling moment is collected as a frequency deviation of -1.0 rad / s and a frequency change rate of 0.5 rad / s. 2 With an active power deviation of 10kW, the time-domain dynamic response is normalized, mapping each value to the interval between -1 and 1, resulting in a normalized frequency deviation of -0.2, a normalized frequency change rate of 0.25, and a normalized active power deviation of 0.4. Based on the negative penalty calculation rules of the time-domain penalty term set, the frequency deviation penalty term -0.2, the frequency change rate penalty term -0.25, and the active power deviation penalty term -0.4 are calculated respectively. The values ​​corresponding to the three penalty terms are then arithmetically added, i.e., -0.2 + (-0.25) + (-0.4) = -0.85, yielding a response penalty result of -0.85 for the continuous action quantity.

[0096] S3.5. Using the stability margin penalty term, the target margin corresponding to the control parameters determined by the continuous motion quantity is substituted into the calculation to obtain the stability margin penalty result.

[0097] The operation of substituting the target margin corresponding to the control parameters determined by the continuous motion quantity into the calculation is achieved through two levels: target margin solution and piecewise formula substitution. In the target margin solution level, the virtual inertia and virtual damping parameters included in the continuous motion quantity are limited by a preset physical constraint range and then transmitted to the parameter input port of the phase margin calculation module. The phase margin calculation module calculates the phase margin corresponding to the current combination of virtual inertia and virtual damping parameters as the target margin, based on the impedance interaction analysis and frequency scanning calculation process described in step S2.2. In the piecewise formula substitution level, according to the piecewise penalty calculation rules described in step S3.2, a preset stability margin threshold and two sets of corresponding weight parameters are read. The target margin and stability margin threshold are compared numerically, and the calculation formula for the corresponding segment is selected based on the comparison result. The target margin, stability margin threshold, and corresponding weight parameters are substituted into the piecewise function formula in step S3.2 to perform arithmetic operations and obtain the stability margin penalty result.

[0098] In this embodiment, based on the continuous motion output in step S3.4, the virtual inertia is 0.3 kg·m. 2 The virtual damping is 15 N·m·s / rad. After being limited and verified by the preset physical constraint range, it is input into the phase margin calculation module. According to the calculation process in step S2.2, the target margin corresponding to the current parameter combination under the heavy load condition of the strong power grid is calculated, which is the phase margin of 18 degrees. According to the segmented penalty calculation rule in step S3.2, the preset stability margin threshold is taken. The penalty weight parameter is 10 degrees. The reward weight parameter is 0.5. The value is 0.2. Comparing the values ​​of the phase margin of 18 degrees and the stability margin threshold of 10 degrees, the calculation formula corresponding to the threshold range is selected and substituted into the numerical calculation to obtain... That is, the stability margin penalty is 1.6.

[0099] S3.6. Generate an instant reward value for the continuous action quantity based on the response penalty result and the stability margin penalty result, and determine the evaluation result based on the instant reward value and the state quantity at the next moment.

[0100] The system reads the values ​​of the response penalty and the stability margin penalty, performs an addition operation on the two sets of values, and the result is the immediate reward value corresponding to the current continuous action quantity. The system matches the corresponding immediate reward value according to a preset mapping rule and determines the evaluation result. The preset mapping rule states that the larger the immediate reward value, the better the overall performance of the corresponding continuous action quantity in terms of frequency dynamic suppression, active power recovery, and small-signal stability margin. A positive immediate reward value indicates that the positive benefit from achieving the stability margin covers the negative penalty caused by the time-domain dynamic deviation, meaning that the current parameter combination meets the stability margin requirements while the time-domain dynamic deviation is within an acceptable range. A negative immediate reward value with a large absolute value indicates that the time-domain deviation penalty is too heavy or the stability margin is insufficient, resulting in poorer overall performance. The entire judgment process does not require the introduction of additional fixed comparison data; it only relies on the reward and penalty design logic of the reward function itself to complete the evaluation. The calculated immediate reward value is matched with the preset mapping rule, and the judgment conclusion corresponding to the current continuous action quantity and the state quantity at the next moment are output as the evaluation result. The evaluation result serves as a feedback signal for the deep reinforcement learning agent, supporting the iterative update of the deep reinforcement learning agent's network parameters.

[0101] In this embodiment, the response penalty result obtained in step S3.4 is -0.85. The response penalty result of -0.85 is obtained by summing the three negative penalty terms: frequency deviation, frequency change rate, and active power deviation, representing the current virtual inertia of 0.3 kg·m. 2The performance loss caused by time-domain dynamic deviation under the virtual damping parameter of 15 N·m·s / rad; the stability margin penalty result obtained in step S3.5 is 1.6. The stability margin penalty result of 1.6 is the positive reward value when the phase margin meets the stability margin threshold requirement, representing the performance gain generated by achieving the stability margin target under the current parameters. After reading the two sets of values, an arithmetic addition operation is performed to obtain the instantaneous reward value corresponding to the continuous motion quantity of 0.75. According to the preset mapping rule, the instantaneous reward value of 0.75 is a positive value, indicating that the positive gain brought by achieving the stability margin target covers the negative penalty of time-domain dynamic deviation. The current virtual inertia is determined to be 0.3 kg·m. 2 The continuous action of virtual damping 15 N·m·s / rad can achieve an acceptable time-domain dynamic response effect while meeting the stability margin requirements, thus obtaining the evaluation results.

[0102] Reference Figure 3 As shown, the iterative update steps include S3.7~S3.10: S3.7 Combine the current state quantity, continuous action quantity, and corresponding evaluation result into an experience sample and store it in the experience replay pool of the deep reinforcement learning agent.

[0103] The system reads the current state of the deep reinforcement learning agent, the continuous actions output by the policy network, and the corresponding evaluation results fed back by the training environment after executing the continuous actions. The evaluation results include the immediate reward value and the state at the next moment. Based on the timestamp of the same interaction cycle, the four sets of data—current state, continuous actions, immediate reward value, and next state—are bound and matched one-to-one to ensure that the four sets of data originate from the same interaction between the agent and the training environment, eliminating data temporal misalignment. The four sets of bound data are arranged in a fixed field order of "current state - continuous actions - immediate reward value - next state," and encapsulated into a single set of structured experience sample data. The experience sample can be represented as... ,in for The state quantity at any given time. for The amount of continuous motion at any given moment. for Instant reward value at any moment for The state quantity at the next time step. The field order is completely consistent with the input order during the training of the deep reinforcement learning agent's action value network, avoiding training errors caused by data order disorder. Experience samples are written to the tail of the pre-allocated experience replay pool storage queue of the deep reinforcement learning agent. If the current number of samples stored in the experience replay pool has reached the preset maximum capacity threshold, the earliest set of experience samples stored at the head of the storage queue is deleted first, and then the current experience sample is written to the tail of the storage queue, maintaining a fixed storage capacity of the experience replay pool and ensuring that the samples in the pool always cover the recent interaction data.

[0104] In this embodiment, based on a single interaction cycle under heavy load conditions of a strong power grid, and according to the state quantity obtained in step S2.3 being a four-element vector [-1.5, 0.8, 15, 15], the continuous action quantity output by the deep reinforcement learning agent in step S3.4 is read as a virtual inertia of 0.3 kg·m. 2 The virtual damping is 15 N·m·s / rad. The corresponding evaluation results from the training environment are read, including the immediate reward value of 0.75 calculated in step S3.6, and the state variables [-0.8, 0.3, 8, 17] up to the next sampling time. The four sets of data are bound and matched one by one according to the timestamp of this interaction to confirm that the data originates from the same interaction cycle between the agent and the training environment. The data is arranged and encapsulated in a fixed order of "current state variable - continuous action quantity - immediate reward value - next time state variable" to obtain a single set of structured experience sample data. The maximum storage capacity of the experience replay pool is set to 10,000 sets, and the current number of samples stored in the pool is 8,500 sets. If the maximum capacity is not reached, the structured experience sample data is directly written to the tail of the storage queue. After writing, the number of samples stored in the experience replay pool is updated to 8,501 sets.

[0105] S3.8. In response to the number of experience samples reaching a preset training threshold, multiple sets of interaction samples are randomly selected from the experience replay pool. A temporal difference objective is calculated based on the multiple sets of interaction samples. The parameters of the action value network in the deep reinforcement learning agent are updated using the temporal difference objective to obtain the updated action value network.

[0106] The total number of experience samples stored in the experience replay pool is continuously counted. The total number of experience samples is compared with the preset training threshold. If the total number of experience samples is greater than or equal to the preset training threshold, the subsequent sample extraction and network update process is started. If the total number of experience samples is less than the preset training threshold, experience samples continue to be accumulated and the update process is not started.

[0107] The total number of sample groups to be extracted is determined according to the preset batch size. A non-repeating random integer index equal to the total number of sample groups to be extracted is generated within the index range of all experience samples in the experience replay pool. The experience sample data at the corresponding position in the experience replay pool is read according to the generated random index. Each group of interactive samples contains four data items: the current state quantity, the continuous action quantity, the immediate reward value, and the next state quantity. All the extracted interactive samples form the training batch dataset.

[0108] The next-time state of each group of interaction samples in the training batch dataset is input into the policy network, which outputs the next-time continuous action quantity corresponding to each group of interaction samples. The next-time state of each group of interaction samples and the next-time continuous action quantity are input into the action value network, which outputs the next-time action value corresponding to each group of interaction samples. A preset discount factor is read, and the immediate reward value, discount factor, and next-time action value of each group of interaction samples are substituted into the temporal difference objective calculation formula to calculate the temporal difference objective for each group of interaction samples. The temporal difference objective calculation formula is as follows: ,in For the first Temporal difference objective of group interaction samples For the first The instant reward value of the group interaction sample, This is a discount factor used to weigh the proportion of immediate rewards against future rewards. For the first The state quantity of the group of interactive samples at the next time step. For the target policy network, The weight parameters of the target policy network, For action value network, These are the weight parameters of the action value network. The parameter update operation of the action value network is implemented through loss calculation and gradient descent. The current state and continuous action quantities of each group of interaction samples in the training batch dataset are input into the action value network. The action value network outputs the current action value corresponding to each group of interaction samples. The mean square error between the current action value of all interaction samples and the corresponding temporal difference objective is calculated, and the mean square error is used as the loss function value of the action value network. The gradient descent algorithm is used to calculate the gradient of the loss function value with respect to all weight parameters of the current action value network. All weight parameters of the action value network are adjusted along the negative direction of the gradient to complete one parameter update. The process of sampling, calculating the temporal difference objective, and updating parameters is repeated until the preset number of updates is reached or the loss function value meets the convergence condition, and the updated action value network is obtained.

[0109] In this embodiment, based on the state of the 8501 sets of experience samples already stored in the experience replay pool in step S3.7, a preset training threshold of 1000 sets is set. The total number of experience samples (8501 sets) is found to be greater than the preset training threshold of 1000 sets, thus initiating the sample extraction and network update process. A preset batch size of 32 sets is set, and 32 unique random integer indices are generated within the sample index range of 0 to 8500. Based on these random indices, 32 sets of interaction samples at corresponding positions in the experience replay pool are read to form the training batch dataset. The training batch dataset includes a set of interaction samples generated from the preceding interaction. These interaction samples include the current state quantity [-1.5, 0.8, 15, 15] and the continuous action quantity virtual inertia of 0.3 kg·m. 2 With virtual damping of 15 N·m·s / rad, instantaneous reward value of 0.75, and next-time state variables [-0.8, 0.3, 8, 17], a discount factor is set. The value is 0.99. The next-time state quantity of the interaction sample generated by the previous interaction is input into the policy network. The policy network outputs the next-time continuous action quantity as a virtual inertia of 0.25 kg·m. 2 The virtual damping is 12 N·m·s / rad. The next-time state quantity of the interaction sample generated by the preceding interaction and the next-time continuous action quantity obtained from the output are jointly input into the action value network. The action value network outputs a next-time action value of 1.2. Substituting into the temporal difference target calculation formula, the temporal difference target corresponding to the interaction sample generated by the preceding interaction is calculated to be 0.75 + 0.99 × 1.2 = 1.938. The current-time state quantity and continuous action quantity of the interaction sample generated by the preceding interaction are jointly input into the current action value network. The current action value network outputs a current action value of 1.5. The mean square error is calculated between the current action value and the corresponding temporal difference target of 32 sets of interaction samples, resulting in a loss function value of 0.082 for the action value network. The gradient descent algorithm is used to calculate the gradient of the loss function value with respect to all weight parameters of the action value network. All weight parameters are adjusted along the negative gradient direction to complete one parameter update. After the update, the loss function value of the action value network decreases to 0.076, resulting in the updated action value network.

[0110] S3.9. Using the action value gradient information output by the updated action value network, optimize the policy gradient of the policy network of the deep reinforcement learning agent to obtain the optimized policy network.

[0111] This is achieved through three levels: action value gradient generation, policy gradient derivation, and policy network parameter optimization.

[0112] Action value gradient generation is achieved through two steps: forward computation and backpropagation. In the first step, the current state of each group of interaction samples in the training batch dataset is input into the policy network. The policy network calculates and outputs the continuous action quantity corresponding to the current state of each group based on its internal weight parameters. In the second step, the current state of each group and the corresponding output continuous action quantity are input into the updated action value network. The partial derivatives of the action value function with respect to each dimension of the continuous action quantity are calculated through backpropagation to obtain the action value gradient information corresponding to each group of samples. The action value gradient information is used to characterize the direction and magnitude of the influence of the numerical adjustment of each dimension of the continuous action quantity on the action value estimate.

[0113] The policy gradient derivation is achieved using the chain rule. Backpropagation is performed on the current policy network to calculate the partial derivative matrices of each dimension of the continuous action quantity with respect to all weight parameters of the policy network. The action value gradient information is then multiplied in the corresponding dimension by the partial derivative matrices of the continuous action quantity with respect to the policy network weight parameters to obtain the policy gradient vector of the policy network optimization objective with respect to all weight parameters of the policy network. This policy gradient vector characterizes the direction and magnitude of the improvement in the desired action value resulting from weight parameter adjustments.

[0114] The optimization of policy network parameters is achieved through the gradient ascent algorithm. According to the preset learning rate, all weight parameters of the policy network are adjusted along the positive direction of the policy gradient vector, so that the action value corresponding to the continuous action output of the policy network gradually increases, and one iteration of the policy network parameters is completed.

[0115] The process of batch sample input, gradient derivation, and parameter adjustment is repeated until the preset number of update steps is reached, resulting in the optimized policy network. The policy gradient calculation formula can be expressed as follows: ,in For the policy gradient of the policy network, The number of interaction sample groups included in the training batch. For the first The current state of the group interaction samples. For the first The policy network outputs continuous action quantities corresponding to the group of interactive samples. For the updated action value network weight parameters, The action value output by the updated action value network. The gradient of action value with respect to the continuous action quantity. These are the weight parameters of the policy network. The continuous action quantities output by the policy network. This represents the gradient of the continuous action quantity with respect to the policy network weight parameters.

[0116] By relying on the updated action value network to provide accurate value evaluation gradient signals, and using the deterministic policy gradient method to guide the policy network to optimize in the continuous action space, the policy network can stably learn the adaptive adjustment law of virtual inertia and virtual damping under multiple working conditions. This gradually improves the comprehensive performance of the parameter tuning scheme in terms of frequency dynamic suppression, active power recovery and small signal stability margin maintenance, avoiding the accuracy loss and optimization oscillation problems caused by discrete parameter search.

[0117] In this embodiment, based on the updated action value network obtained in step S3.8 and the training batch dataset containing 32 sets of interaction samples, one set of interaction samples generated by the preceding interaction is selected. The current state of the interaction sample generated by the preceding interaction is [-1.5, 0.8, 15, 15]. The current state of the interaction sample generated by the preceding interaction is input into the policy network. The policy network calculates and outputs the corresponding continuous action quantity as a virtual inertia of 0.3 kg·m based on its internal weight parameters. 2 The virtual damping is 15 N·m·s / rad. The current state quantity and continuous action quantity of the interaction samples generated from the preceding interaction are input into the updated action value network. The gradient of the action value with respect to the continuous action quantity is calculated through backpropagation, where the gradient value for the virtual inertia dimension is 0.6 and the gradient value for the virtual damping dimension is 0.4. Backpropagation is then performed on the current policy network to calculate the partial derivative matrix of the continuous action quantity with respect to the policy network weight parameters. The action value gradient and the partial derivative matrix are multiplied in the corresponding dimension to obtain the policy gradient vector of the policy network. The gradient ascent algorithm is used, with a learning rate of 0.001, and all weight parameters of the policy network are adjusted along the positive direction of the policy gradient vector. After completing the batch gradient calculation and parameter update for 32 sets of samples, the policy network updates the continuous action quantity output for the same state quantity to a virtual inertia of 0.32 kg·m. 2 With a virtual damping of 15.8 N·m·s / rad, the estimated action value is increased from 1.5 to 1.62, resulting in the optimized policy network.

[0118] S3.10. Perform soft parameter updates on the target networks corresponding to the updated action value network and the optimized policy network to obtain the updated deep reinforcement learning agent.

[0119] The parameter soft update operation performs a parameter-wise weighted fusion of the target networks corresponding to the updated action-value network and the optimized policy network, respectively. This achieves smooth iteration of the target network parameters through a fixed-coefficient weighting operation. The soft update calculation formula is as follows: ,in The weight parameters of the target network, To correspond to the weight parameters of the current network, The soft update coefficient, with a value between 0 and 1, controls the rate at which the target network approximates the current network parameters. The smaller the soft update coefficient, the smaller the magnitude of the target network parameter update, and the higher the stability of the deep reinforcement learning training process. After the target networks corresponding to the action value network and policy network have completed their parameter soft updates, they, together with the updated action value network, the optimized policy network, and the experience replay pool, constitute the updated deep reinforcement learning agent.

[0120] In this embodiment, a preset soft update coefficient is set based on the updated action value network and the optimized policy network obtained in step S3.9. The value is 0.001. Taking a set of weight parameters from the first hidden layer of the action value network as a calculation example, the updated action value network has a corresponding weight parameter value of 0.42, while the original action value network had a corresponding weight parameter value of 0.38. Substituting these values ​​into the soft update calculation formula, the new corresponding weight parameter value of the target action value network is calculated to be 0.001×0.42+(1-0.001)×0.38=0.38004. The same element-wise weighted operation method is used to complete the soft update of all weight parameters at all levels of the action value network, replacing all the original weight parameters of the target network. Using a set of weight parameters from the output layer of the policy network as a calculation example, the optimized policy network has a corresponding weight parameter value of 0.56, while the original policy network had a corresponding weight parameter value of 0.51. Substituting these values ​​into the same soft update calculation formula, the new corresponding weight parameter value for the policy network is calculated to be 0.001×0.56+(1-0.001)×0.51=0.51005. The same element-wise weighted operation method is then used to complete the soft update of all weight parameters across all levels of the policy network, replacing all the original weight parameters of the target network. After the action value network and the policy network's respective target networks have completed their parameter soft updates, they, together with the updated action value network, the optimized policy network, and the experience replay pool storing 8501 sets of experience samples, constitute the updated deep reinforcement learning agent.

[0121] S4. Based on the updated deep reinforcement learning agent, output continuous action quantities according to the state quantities, map the continuous action quantities to a preset physical constraint range, and apply them to the outer active frequency control link in the virtual synchronous generator control.

[0122] The iteratively updated deep reinforcement learning agent retains the converged policy network as the parameter output network. Normalization is performed on frequency deviation, rate of change of frequency, active power deviation, and phase margin to unify the dimensions and numerical ranges of the four types of state variables, eliminating the interference of dimensional differences on network computational stability. After receiving the normalized state variables, the policy network outputs continuous action quantities in the corresponding dimensions. In the basic implementation, it outputs two continuous action quantities: virtual inertia and virtual damping. In the extended implementation, which introduces virtual impedance parameters, it simultaneously outputs continuous action quantities of virtual resistance and virtual reactance.

[0123] The step of mapping the continuous motion quantity to a preset physical constraint range includes S4.1 to S4.4: S4.1 Identify the control parameter type corresponding to the continuous motion quantity, and determine the physical constraint boundary corresponding to the preset physical constraint range based on the control parameter type.

[0124] The system reads the continuous action quantities output by the deep reinforcement learning agent, extracts the parameter labels bound to the vectors of each dimension of the continuous action quantities, and performs string matching between the extracted parameter label data of each dimension and the pre-stored list of control parameter types in the control system. After a successful match, the control parameter type corresponding to each dimension of the continuous action quantity is obtained. The control parameter types include two basic types: virtual inertia and virtual damping. In the extended scenario of introducing virtual impedance parameters, the control parameter types also include virtual resistance and virtual reactance.

[0125] For each type of control parameter that has been matched, the parameter constraint mapping table stored in the control system storage unit is accessed. The upper limit value and lower limit value bound to the corresponding control parameter type are retrieved from the parameter constraint mapping table. The upper and lower limit values ​​are pre-calibrated by the main circuit hardware parameter threshold of the grid-type inverter controlled by the virtual synchronous generator, the small signal stability constraint conditions of the control loop, and engineering operation experience. The retrieved upper limit value and lower limit value together constitute the physical constraint boundary of the corresponding control parameter type.

[0126] In this embodiment, the deep reinforcement learning agent outputs a continuous motion vector with two dimensions. The preset parameter label bound to the first dimension of the vector is "virtual inertia," and the parameter label bound to the second dimension is "virtual damping." The parameter labels of the two dimensions of the continuous motion vector are read, and each of these labels is matched against a pre-stored list of control parameter types. After matching, the virtual inertia control parameter type corresponding to the first dimension of the continuous motion is determined, and the virtual damping control parameter type corresponding to the second dimension of the continuous motion is determined. The pre-stored parameter constraint mapping table is accessed, and the physical lower limit corresponding to the virtual inertia control parameter type is found to be 0.08 kg·m. 2 The upper limit of the physical value is 1.8 kg·m 20.08 kg·m 2 With 1.8 kg·m 2 The physical constraint boundary corresponding to the virtual inertia is determined; the physical value lower limit corresponding to the virtual damping control parameter type is 8 N·m·s / rad and the physical value upper limit is 45 N·m·s / rad, and 8 N·m·s / rad and 45 N·m·s / rad are determined as the physical constraint boundary corresponding to the virtual damping.

[0127] S4.2. Scale the continuous motion quantity using the physical constraint boundary to obtain an initial setpoint value limited to the physical constraint range.

[0128] Scaling is performed through a linear interval mapping operation. The lower and upper limits of the physical values ​​within the physical constraint boundary of the corresponding control parameter type are read. The difference between the upper and lower limits is calculated to obtain the span of the value range for the corresponding control parameter type. The original values ​​of the continuous action quantities in the corresponding dimension, output by the policy network of the deep reinforcement learning agent, are read. These original values ​​fall within the standard output range preset by the neural network. The original values ​​of the continuous action quantities are multiplied by the value range span. The result of this multiplication is then added to the lower limit of the physical values ​​to obtain the parameter values ​​output by the mapping operation. These parameter values ​​are the initial tuning values ​​limited to the physical constraints.

[0129] In this embodiment, based on the physical constraint boundary determined in step S4.1, the lower limit of the physical value corresponding to the virtual inertia is 0.08 kg·m. 2 The upper limit of the physical value is 1.8 kg·m 2 The calculated range of the virtual inertia is 1.72 kg·m. 2 The lower limit of the physical value corresponding to the virtual damping is 8 N·m·s / rad, and the upper limit is 45 N·m·s / rad. The calculated range of the virtual damping value is 37 N·m·s / rad. The continuous action output of the deep reinforcement learning policy network is within the standard output range of [0,1]. The original value of the continuous action in the virtual inertia dimension is 0.4, and the original value of the continuous action in the virtual damping dimension is 0.6. After performing a scaling operation on the virtual inertia dimension, the initial tuning value corresponding to the virtual inertia is 0.768 kg·m. 2 Scaling operations were performed on the virtual damping dimension to obtain an initial tuning value of 30.2 N·m·s / rad for the virtual damping. Both the initial tuning values ​​of the virtual inertia and the virtual damping are within the corresponding physical constraints.

[0130] S4.3. Based on the initial set value, query the parameter change rate limit value corresponding to the control parameter type. Using the target set value of the previous control cycle as a comparison benchmark, calculate the parameter change amount between the initial set value and the comparison benchmark. Use the parameter change rate limit value to limit the parameter change amount to obtain the target set value.

[0131] Read the type identifier data of the corresponding control parameter type, access the parameter change rate constraint mapping table pre-stored in the control system storage unit, retrieve the parameter change rate limit value bound to the corresponding control parameter type from the parameter change rate constraint mapping table, and the parameter change rate limit value is pre-calibrated by the dynamic stability constraint conditions of the active frequency control link controlled by the virtual synchronous generator.

[0132] The target setpoint value from the previous control cycle is read and stored as the parameter reference value. The difference between the initial setpoint value and the parameter reference value at the current moment is calculated to obtain the single-step parameter change. The absolute value of the single-step parameter change is extracted and compared with the parameter change rate limit. If the absolute value of the single-step parameter change is less than or equal to the parameter change rate limit, the initial setpoint value at the current moment is directly determined as the target setpoint value. If the absolute value of the single-step parameter change is greater than the parameter change rate limit, the sign of the single-step parameter change is retained, and the signed parameter change rate limit is superimposed on the parameter reference value. The value obtained by the superposition operation is determined as the target setpoint value.

[0133] Limiting is used to constrain the single-step adjustment range of control parameters, avoid drastic fluctuations in system frequency and active power caused by parameter mutations, and ensure the smoothness and stability of the virtual synchronous generator control process.

[0134] In this embodiment, the initial virtual inertia tuning value of 0.768 kg·m obtained in step S4.2 is used. 2 With the initial virtual damping setpoint of 30.2 N·m·s / rad, the control parameter type identifiers corresponding to the virtual inertia and virtual damping are read, the pre-stored parameter rate of change constraint mapping table is accessed, and the parameter rate of change limit value corresponding to the virtual inertia is found to be 0.2 kg·m. 2 The limit value for the rate of change of the virtual damping parameter is 4 N·m·s / rad. The virtual inertia target tuning value of 0.5 kg·m stored in the previous control cycle is read. 2 The virtual damping target setpoint of 25 N·m·s / rad is used as the parameter reference value. The calculated single-step parameter change of the virtual inertia is 0.768 kg·m. 2 Subtract 0.5 kg·m 2 The result was 0.268 kg·m 2 The absolute value extracted is 0.268 kg·m2 With 0.2 kg·m 2 Comparison, 0.268 kg·m 2 Greater than 0.2 kg·m 2 Keep the positive sign, at 0.5 kg·m 2 Add 0.2 kg·m on top of the base 2 The virtual inertia target tuning value was obtained as 0.7 kg·m. 2 The change in virtual damping parameters at a single step is calculated as 30.2 N·m·s / rad minus 25 N·m·s / rad, yielding 5.2 N·m·s / rad. The absolute value of 5.2 N·m·s / rad is extracted and compared with 4 N·m·s / rad, retaining the positive sign. 4 N·m·s / rad is then added to the 25 N·m·s / rad value to obtain the virtual damping target setpoint of 29 N·m·s / rad.

[0135] S4.4 Output the target tuning value as the result of mapping the continuous motion quantity to the physical constraint range.

[0136] Read the target setpoint value corresponding to each type of control parameter, attach an identifier field corresponding to the control parameter type to each target setpoint value, and generate parameter output data with type labels. Send the parameter output data with type labels to the parameter storage register of the corresponding control loop in the virtual synchronous generator control system. Write the virtual inertia target setpoint value into the virtual inertia parameter register of the outer active frequency control loop in the virtual synchronous generator control system, and write the virtual damping target setpoint value into the virtual damping parameter register of the outer active frequency control loop in the virtual synchronous generator control system.

[0137] In the extended scenario introducing virtual impedance parameters, the target setpoints for virtual resistance and virtual reactance are written into the virtual impedance parameter register of the voltage reference compensation stage, completing the real-time loading and application of control parameters. The target setpoints corresponding to all control parameter types at the current moment are written into the historical parameter cache unit of the virtual synchronous generator control system, overwriting the target setpoint data stored in the previous control cycle. This serves as the reference value for parameter rate-of-change limiting processing in the next control cycle, enabling the continuous action output of the deep reinforcement learning agent's policy network to directly affect the virtual synchronous generator control stage, while ensuring the smoothness of parameter adjustments between adjacent control cycles.

[0138] In this embodiment, the virtual inertia target tuning value of 0.7 kg·m is calculated according to step S4.3. 2 The virtual damping target setting is 29 N·m·s / rad, which is 0.7 kg·m. 2Add a virtual inertia type identifier field, and add a virtual damping type identifier field to 29 N·m·s / rad, generating two sets of parameter output data with type labels. The 0.7 kg·m value with the virtual inertia type label will be used as an example. 2 The numerical value is written to the virtual inertia parameter register of the outer active power frequency control loop in the virtual synchronous generator control. The value of 29 N·m·s / rad with the virtual damping type label is written to the virtual damping parameter register of the outer active power frequency control loop in the virtual synchronous generator control, so that the active power frequency control loop operates according to the updated virtual inertia and virtual damping parameters. 0.7 kg·m 2 The historical parameter cache unit of the control system, with a value of 29 N·m·s / rad, is written, overwriting the 0.5 kg·m stored in the previous cycle. 2 The data of 25 N·m·s / rad is used as the baseline value for calculating the single-step parameter change in the next control cycle.

[0139] Example 3 is an embodiment of the present invention, which provides an adaptive tuning system for control parameters of a grid-type inverter, comprising: The training environment construction module is used to build a training environment for a grid-connected inverter controlled by a virtual synchronous generator; The state quantity acquisition module is used to acquire the state quantities of the grid-type inverter during operation in the training environment; The agent update module is used to construct a reward function. In each training round, the reward function is used to evaluate the continuous action output of the deep reinforcement learning agent, and the deep reinforcement learning agent is iteratively updated based on the evaluation results. The control parameter tuning module is used to output continuous action quantities based on the updated deep reinforcement learning agent according to the state quantity, map the continuous action quantities to a preset physical constraint range, and act on the outer active frequency control link in the virtual synchronous generator control.

[0140] This embodiment also provides a computer device applicable to an adaptive tuning method for control parameters of a grid-connected inverter, comprising: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the adaptive tuning method for control parameters of a grid-connected inverter as proposed in the above embodiment.

[0141] This embodiment also provides a storage medium storing a computer program that, when executed by a processor, implements an adaptive tuning method for control parameters of a grid-type inverter as proposed in the above embodiments.

[0142] The storage medium proposed in this embodiment and the method for adaptive tuning of control parameters of a grid-type inverter proposed in the above embodiments belong to the same inventive concept. Technical details not described in detail in this embodiment can be found in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.

[0143] Based on the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented using software and necessary general-purpose hardware, and of course, it can also be implemented using hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk, or optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of the various embodiments of the present invention.

[0144] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims

1. An adaptive tuning method for control parameters of a grid-connected inverter, characterized in that, Includes the following steps: Construct a training environment for a grid-connected inverter controlled by a virtual synchronous generator; Collect the state variables of the grid-type inverter during its operation in the training environment; Construct a reward function, and in each training round, use the reward function to evaluate the continuous action output of the deep reinforcement learning agent, and iteratively update the deep reinforcement learning agent based on the evaluation results; Based on the updated deep reinforcement learning agent, continuous action quantities are output according to the state variables, and the continuous action quantities are mapped to a preset physical constraint range, which are then applied to the outer active frequency control link in the virtual synchronous generator control.

2. The adaptive tuning method for control parameters of a grid-connected inverter as described in claim 1, characterized in that, The steps for constructing the training environment include: Build a basic simulation model for a grid-type inverter; In the basic simulation model, different operating conditions are generated by configuring the equivalent impedance of the power grid and the reference value of active power, thus obtaining a multi-condition simulation model. Based on the impedance interaction characteristics between the equivalent admittance on the grid-connected inverter side and the equivalent admittance on the grid side, a phase margin calculation module is constructed. The phase margin calculation module is connected to the multi-condition simulation model to establish a data interaction link and obtain the training environment.

3. The adaptive tuning method for control parameters of a grid-connected inverter as described in claim 2, characterized in that, The steps for acquiring the state variables include: The time-domain dynamic response of the grid-type inverter during operation in the training environment is collected; The phase margin is calculated by analyzing the impedance interaction relationship between the equivalent admittance on the grid-connected inverter side and the equivalent admittance on the grid side. The time-domain dynamic response and the phase margin are used together as the state variables of the deep reinforcement learning agent.

4. The adaptive tuning method for control parameters of a grid-connected inverter as described in claim 3, characterized in that, The steps for constructing the reward function include: Construct a set of time-domain penalty terms; The phase margin is compared with the preset stability margin threshold in segments to obtain the comparison result. Based on the comparison result, a stability margin penalty term is generated in combination with the preset weight parameters. The reward function is obtained by adding the values ​​of each item in the set of time-domain penalty terms to the value of the stability margin penalty term.

5. The adaptive tuning method for control parameters of a grid-connected inverter as described in claim 4, characterized in that, The evaluation process includes the following steps: The time-domain dynamic response quantity is subjected to response constraint analysis using the set of time-domain penalty terms to obtain the response penalty result; Using the stability margin penalty term, the target margin corresponding to the control parameters determined by the continuous action quantity is substituted into the calculation to obtain the stability margin penalty result; An instantaneous reward value for the continuous action quantity is generated based on the response penalty result and the stability margin penalty result, and the evaluation result is determined based on the instantaneous reward value and the state quantity at the next moment.

6. The adaptive tuning method for control parameters of a grid-connected inverter as described in claim 5, characterized in that, The steps for iterative updates include: The current state quantity, continuous action quantity, and corresponding evaluation result are combined into an experience sample and stored in the experience replay pool of the deep reinforcement learning agent. When the number of experience samples reaches a preset training threshold, multiple sets of interaction samples are randomly selected from the experience replay pool. A temporal difference objective is calculated based on the multiple sets of interaction samples. The parameters of the action value network in the deep reinforcement learning agent are updated using the temporal difference objective to obtain the updated action value network. Using the action value gradient information output by the updated action value network, the policy gradient of the deep reinforcement learning agent is optimized to obtain the optimized policy network. The target networks corresponding to the updated action value network and the optimized policy network are subjected to soft parameter updates to obtain the updated deep reinforcement learning agent.

7. The adaptive tuning method for control parameters of a grid-connected inverter as described in claim 6, characterized in that, The step of mapping the continuous motion quantity to a preset physical constraint range includes: Identify the control parameter type corresponding to the continuous motion quantity, and determine the physical constraint boundary corresponding to the preset physical constraint range based on the control parameter type; The continuous motion quantity is scaled using the physical constraint boundary to obtain an initial setpoint value limited to the physical constraint range. Based on the initial setpoint, query the parameter change rate limit value corresponding to the control parameter type. Using the target setpoint value of the previous control cycle as a comparison benchmark, calculate the parameter change amount between the initial setpoint value and the comparison benchmark. Use the parameter change rate limit value to limit the parameter change amount to obtain the target setpoint value. The target tuning value is output as the result of mapping the continuous motion quantity to the physical constraint range.

8. An adaptive tuning system for control parameters of a grid-connected inverter, employing the adaptive tuning method for control parameters of a grid-connected inverter as described in any one of claims 1-7, characterized in that, include: The training environment construction module is used to build a training environment for a grid-connected inverter controlled by a virtual synchronous generator; The state quantity acquisition module is used to acquire the state quantities of the grid-type inverter during operation in the training environment; The agent update module is used to construct a reward function. In each training round, the reward function is used to evaluate the continuous action output of the deep reinforcement learning agent, and the deep reinforcement learning agent is iteratively updated based on the evaluation results. The control parameter tuning module is used to output continuous action quantities based on the updated deep reinforcement learning agent according to the state quantity, map the continuous action quantities to a preset physical constraint range, and act on the outer active frequency control link in the virtual synchronous generator control.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the adaptive tuning method for control parameters of a grid-type inverter according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the adaptive tuning method for control parameters of a grid-type inverter according to any one of claims 1 to 7.