## 1 Introduction
However, the fluctuation of grid impedance caused by load throwing will not only reduce the stability margin of the inverter but also cause harmonic resonance or even instability of the inverter [22]. The main cause of this phenomenon is the use of phase-locked loop in the current source. In [PERSON] et al. [21], the authors proposed a nonlinear PLL, and their conclusions showed that impedance fluctuations can cause self-synchronization phenomena in the PLL, which can lead to inverter instability. [PERSON] et al. [23] proposed a unified impedance model for grid-connected inverters, and their conclusions showed that a higher PLL bandwidth would lead to harmonic resonance in weak grids. In summary, current-source inverters are suitable for strong grids, while their stability is reduced under weak grids and even unstable under very weak grids. On the contrary, voltage-source inverters in a weak grid have better stability, while the system is not stable in a strong grid. Therefore, the voltage-source mode is chosen for energy compensation in this paper. The virtual synchronous generator (VSG) is a voltage-based converter that has been widely used in the field of new energy generation [24]. It can simulate the inertia and damping characteristics of conventional synchronous generators. VSGs applied in distributed generation have the following characteristics [25]. First, a VSG can provide inertia support to microgrids, which helps to reduce the frequency deviation when load changes or faults occur. Second, compared with the traditional voltage source converter, the operation of a VSG does not depend on the phase angle of the microgrid voltage, which avoids the instability problem due to the phase-locked loop (PLL) [26]. In addition, the VSG achieves frequency and voltage droop control through its active power-frequency control and re active power-voltage control, thus improving power angle stability and system voltage stability by using only local communication. For voltage source inverters, in addition to the droop control and virtual synchronous control mentioned above, direct power control has attracted the attention of scholars because of its simple algorithm structure and high power factor [27, 28]. Note that the power equation of the inverter side in this paper is borrowed from the literature [27]. In the conventional direct power control method, not only is a large amount of tuning required, but large harmonics of the bus voltage can also occur in the presence of grid impedance distortion. [PERSON] et al. [29] proposed an online inductance identification technique based on the gradient correction method based on extended power theory and combined it with DPC to improve the robustness of DPC. [PERSON] et al. [30] proposed a control strategy for a voltage source pulse-width modulated (PWM) rectifier inverter based on direct power control. Although the proposed DPC technique can fully regulate the stability of the output current without special compensation blocks, its experimental results show that its output current has a certain degree of distortion. Therefore, we design and propose the control strategy of the compensation device based on direct power control. After analyzing the above discussion, in this paper, we present a controller scheme: (i) transforming the transient mathematical model of the voltage-source PWM inverter into a power model, with the help of transient power theory; (ii) designing adaptive frequency controller to implement the frequency tracking control; (iii) designing the NAMIMO controller to control compensation device to compensate impact loads. The contributions of this paper are as follows: (i) we designed a NAMIMO controller to implement impact load compensation for natural gas generators; (ii) The frequency adaptive law of the controller not only improved power transient response characteristics but also realized power differential regulation. This paper is organized below. Section 2. mainly establishes the direct power model of the compensation system and the generator system.