A Two-Layer Optimization Strategy for Battery Energy Storage Systems to Achieve Primary Frequency Regulation of Power Grid

: A two-layer optimization strategy for the battery energy storage system is proposed to realize primary frequency regulation of the grid in order to address the frequency ﬂuctuation problem caused by the power dynamic imbalance between the power system and load when a large number of new energy sources are connected to the grid. An integrated control mode combining virtual sag control and virtual inertia control is proposed in the adaptive regulation layer to provide fast frequency support for the grid while effectively reducing steady-state frequency difference ﬂuctuation. The equal consumption micro-increment criterion is used in the equalization control layer to distribute the energy output of each group while maintaining a good battery charge level. The results of the ﬁnal simulation in Matlab/Simulink show that the proposed control strategy can effectively improve the system’s primary frequency regulation performance.


Introduction
With the increasing penetration of new energy [1][2][3], the uncertainty and instability of its regulation will pose significant risks to the long-term safe operation of the power system, resulting in low inertia and weak damping of the power grid, making the frequency more variable under power disturbance, while traditional units, due to their limited regulation capacity and other issues, are also not conducive to the safety and stability of the power grid [4].
Energy storage has a strong short-term power throughput capacity, bi-directional regulation, and the ability to accurately track [5], and has become an important FM resource to solve the problems of traditional units, with the response rate of battery energy storage systems (BESSs) being more than 60 times that of traditional FM units [6][7][8]; so, the use of an energy storage battery system for frequency regulation is currently popular.As a result, the use of BESSs for frequency regulation is a hot research topic.The literature [9] demonstrates that BESSs have great potential for providing grid-assisted services and proposes corresponding corrective energy measures and control algorithms to allow the batteries involved in FM services to continuously maintain their state of charge within the limits.The literature [10] proposes a new method for the optimal allocation of battery energy storage capacity, taking into account the rate characteristics of primary frequency regulation, which solves the problem of battery energy storage capacity limitation during primary frequency regulation.According to the literature [11], large-scale battery energy storage, as a new flexible market player, can arbitrage in the energy market and profit from providing primary FM services.
For BESSs to participate in primary frequency regulation of the grid, there are two main control modes: (1) virtual inertia control (VIC) can effectively suppress the rate of change in Energies 2023, 16, 2811 2 of 18 frequency deviation, thus providing fast frequency support to the grid [12], and (2) virtual droop control (VDC) can effectively reduce steady-state frequency deviation fluctuations and improve grid frequency stability [13].The literature [14] employs sag control to dynamically coordinate the frequency regulation process of energy storage under various operating conditions, which is advantageous to the functionality and economy of energy storage but does not provide fast support for grid frequency deviation.The literature [15,16] compared the constant sag coefficient method to the linear sag coefficient method, which uses a constant sag coefficient value to control the energy storage output but does not take into account the battery frequency regulation capability and is prone to damaging the battery life by overcharging and over-discharging the battery, whereas the linear sag coefficient method uses simple linear control but has a poor ability to follow the state of charge.The linear sag factor approach employs straightforward linear control, but it has a poor ability to track the battery's state of charge (SOC).The dead zone of energy storage and frequency regulation is employed in the literature [17] as the segmentation boundary for energy storage and frequency regulation, and the virtual sag coefficient is calculated using an S-shaped function to manage the system frequency difference.According to the literature [18], double-layer fuzzy control is used to regulate the energy storage system's output and virtual sag coefficient while taking battery SOC into account.This method can increase the effect of frequency regulation, but still falls short in terms of quick regulation.
To achieve a better FM effect, two control modes are frequently combined using refs.[19,20], by setting a reasonable threshold value for mode switching and switching mode [21], whereby the advantages of both can be achieved to complement each other, effectively improving the FM effect.The literature [22] demonstrates that combining the two control methods yields better results.The literature [23] only used VIC for frequency regulation, which could not solve the problem of the grid experiencing long-term steady-state fluctuations.The literature [24] uses the VIC mode before the frequency difference reaches its maximum value and directly switches to the VDC mode after the frequency difference reaches its maximum value, but direct switching results in output power fluctuations at the switching point.To address this issue, the literature [25] proposed a proportional model for VDC mode and VIC mode distribution that can achieve smooth switching between the two control modes while avoiding output fluctuations.A reasonable allocation of the two modes is combined with a regression function for adaptive frequency regulation in the literature [26] to determine the FM output of the energy storage.To avoid secondary disturbances at the switching point while satisfying the SOC constraint, the literature [27] smoothly switches between the two control modes while adaptively adjusting the energy storage output based on the battery SOC.The literature [28] proposes an adaptive factor to correct the FM coefficients, but the dynamic regulation capability of this method is severely limited.The literature [29] establishes a two-stage robust approximate dynamic programming optimization model to control the output of FM power, but this control scheme lacks long-term use and has a long response time.A state space prediction model for energy storage frequency regulation has been established in the literature [30] to control the grid frequency by predicting the state and rolling optimization, but the method does not take energy storage frequency regulation capability into account, and long-term use may easily result in storage unit damage.
The literature cited above can demonstrate the feasibility and necessity of BESS participation in primary frequency regulation of the grid, as well as the mode switching problem and frequency regulation capability of energy storage participation in frequency regulation, but there are some shortcomings and improvements required: (1) the variable sag coefficient method used in [14,15,18,19,31] for frequency regulation has insufficient adaptive capability; (2) the lack of consideration of technical characteristics such as energy storage charge state and climbing rate in the literature [28,29] can be constrained by the constraint function of the energy storage out process; and (3) the majority of the current literature does not consider the scenario of multiple groups of energy storage participating Energies 2023, 16, 2811 3 of 18 in one frequency regulation, and when multiple groups of BESSs participate in frequency regulation together, it is easy to cause the BESSs with latencies.
To address the common deficiencies in the current literature, this paper proposes a two-layer control strategy involving multiple groups of BESSs involved in FM.First, a regional dynamic-response-model-based integrated control mode that takes VIC and VDC into account is proposed.Second, a high-precision fuzzy controller is designed in the upper layer to achieve the adaptive switching of the two control modes, whereas in the lower layer, the load state constraints on the energy storage capacity constraints are taken into account while equalizing the FM output of each group of BESS based on equal consumption micro-incremental criterion control.Finally, simulation is used to validate the proposed strategy's effectiveness.

Regional Grid Primary FM Model with Multiple BESSs
The dynamic response model of multiple energy storage batteries participating in grid primary frequency regulation based on regional equivalence [21], which consists of the dispatch center's control unit and the FM power supply, can be used to realize primary frequency regulation.The region is set up with one conventional unit and J BESSs for frequency regulation, totaling 1 + J FM power supplies.Figure 1 depicts the dynamic response model for region i and Table 1 defines the model's parameters.

Conventional unit
Primary FM In region i, the conventional unit is a reheat-type thermal unit, and t primarily of the thermal unit governor model and the reheat-type tu complex frequency domain expressions of the conventional unit mode  In region i, the conventional unit is a reheat-type thermal unit, and the model consists primarily of the thermal unit governor model and the reheat-type turbine model.The complex frequency domain expressions of the conventional unit model G g (s) are as follows:

Multi
where Gov_ H (s) is the governor transfer function, Gov_ RT (s) is the turbine transfer function, ∆Y (s) is the variation in the turbine steam valve opening, T CH , T RH , and T CO are the high-pressure steam volume time constants, reheat steam volume time constants, and low-pressure steam volume time constants, and F HP , F IP , and F LP are the power coefficients of the high-pressure, medium-pressure, and low-pressure cylinders.
The battery energy storage system is based on the first-order inertia model, which can accurately simulate the dynamic characteristics of the energy storage system and the grid in the active exchange state while taking into account the system's charge state constraint.In the complex frequency domain, the battery energy storage model G Bj (s) is expressed as follows: where T B is the energy storage time constant, and Q SOCjmax and Q SOCjmin are the maximum and minimum values of the battery charge state.

Control Structure of VIC and VDC
The control methods of the BESS involved in grid primary frequency regulation are divided into virtual inertia control (VIC) and virtual sag control (VDC).As shown in Figure 2a,b, when virtual inertia control is used in the complex frequency domain, let K B = sK BI , and when virtual sag control is used, let The control methods of the BESS involved in grid primary freq divided into virtual inertia control (VIC) and virtual sag control (VD ure 2a,b, when virtual inertia control is used in the complex freque sKBI, and when virtual sag control is used, let KB = KBD. -KG Solving the rate of change in the frequency deviation θI and the yields Ignoring the FM dead-band and limiting constraint, from Figure 2a, we have The final frequency deviation in the VIC control mode is obtained as Solving the rate of change in the frequency deviation θ I and the steady-state value Similarly, from Figure 2b, it follows that The final frequency deviation in the VDC control mode is obtained as Energies 2023, 16, 2811 Solving the rate of change in the frequency deviation θ D and the steady-state value

Integrated Control Strategy Based on VIC and VDC
From Equation ( 5), it can be seen that after adding the disturbance ∆P Li (s) in the complex frequency domain, if the VIC mode is used, the rate of change in frequency deviation θ I depends on the rotational inertia of the grid's system M i and the BESS virtual inertia coefficient K BI , and the steady-state value of frequency deviation e ssI depends on the damping coefficient of the grid's system D i and the primary frequency regulation coefficient of the conventional unit K G ; so, the VIC mode can quickly suppress the rate of change in the frequency deviation, but causes no improvement in the steady-state deviation effect.As can be seen from Equation ( 8), after adding the disturbance ∆P Li (s), if the VDC mode is used, the frequency deviation change rate θ D depends only on the grid's system rotational inertia M i , and the steady-state value of frequency deviation e ssD depends on the BESS's virtual sag coefficient K BD and the conventional unit primary frequency regulation coefficient K G ; therefore, the VDC mode can improve the steady-state frequency deviation very well, but has no improvement effect on the frequency deviation change rate.
To meet the frequency regulation demand of the power grid, comprehensive consideration of the advantages of the VIC and VDC modes in the frequency regulation process set the total frequency regulation output of the energy storage battery consisting of both, and at the same time to better achieve a smooth transition between the two modes, virtual inertia allocation factor α 1 and virtual sag allocation factor α 2 are introduced for VIC and VDC modes, respectively; so, the total primary frequency regulation output of the battery energy storage system in the time domain is where d∆f i (t)/dt is the rate of change in the frequency deviation, and the virtual inertia allocation factor α 1 and virtual sag allocation factor α 2 satisfy α 1 + α 2 = 1.

Two-Tier Control Structure
This paper takes into account the technical characteristics of each group of BESS and proposes a two-layer control strategy for multiple BESS groups to achieve the primary frequency regulation of the grid based on meeting the demand for grid frequency regulation in order for multiple BESS groups to participate in the primary frequency regulation of the grid mode allocation and power balance.The flow chart of the two-level control strategy is shown in Figure 3.
The upper layer is the adaptive regulation layer; to adapt to the demand of grid frequency regulation, the advantages of two control modes of VIC and VDC in the process of frequency regulation are fully considered, and the fuzzy control is used to allocate the participation degree of the two modes to achieve the smooth switching of the two modes while suppressing the secondary fluctuation at the switching point, and finally, the total output of multiple BESS groups participating in primary frequency regulation is obtained.The equalization control layer is the lowest layer; with the objective of optimal power distribution for multiple BESSs participating in primary FM, the differences between the technical characteristics of each group of batteries are fully considered, and the total power output of primary FM is balanced to each group of BESS based on the criterion of equal consumption micro-increase rate while maintaining a good battery charge level, and finally, the final power output of each group of BESS after balanced control is obtained.
The requirement of grid frequency regulation is met while the coordinated operation of numerous BESSs is achieved through the progressive control of upper and lower levels.
The equalization control layer is the lowest layer; with the objective of optimal po tribution for multiple BESSs participating in primary FM, the differences betw technical characteristics of each group of batteries are fully considered, and t power output of primary FM is balanced to each group of BESS based on the crit equal consumption micro-increase rate while maintaining a good battery charge le finally, the final power output of each group of BESS after balanced control is o The requirement of grid frequency regulation is met while the coordinated oper numerous BESSs is achieved through the progressive control of upper and lower

Adaptive Regulation Layer
Based on the control modes of VIC and VDC, the fuzzy controller of the a regulation layer aims at the frequency regulation demand of the grid and takes the frequency deviation Δfi(t) and the system frequency deviation change rate dΔfi(t)/ time domain as input quantities, thus determining the allocation factors α α2(t)(α2(t) = 1 − α1(t)) for both control modes of VIC and VDC.
The first layer of the fuzzy controller is a two-dimensional control with norma coefficients k1, k2, and k3 for the input quantities Δfi(t) and dΔfi(t)/dt and the outpu tity α1(t), as shown in Equation (10).
where ΔF(t) is the allowable interval of primary FM, and Δfimax(t) is the maximu of frequency deviation.
The Mamdani-type affiliation function is chosen as the affiliation function.Δ dΔfi(t)/dt are the two inputs of the fuzzy controller with the theoretical domain [-1,1] and α1(t) is the output of the fuzzy controller with the theoretical domain [0,1].The fuzzy sets are {NB(negative large), NM(negative medium), NS(negativ ZO(zero), PS(positive small), PM(positive medium), PB(positive large)}.

Adaptive Regulation Layer
Based on the control modes of VIC and VDC, the fuzzy controller of the adaptive regulation layer aims at the frequency regulation demand of the grid and takes the system frequency deviation ∆f i (t) and the system frequency deviation change rate d∆f i (t)/dt in the time domain as input quantities, thus determining the allocation factors α 1 (t) and α 2 (t)(α 2 (t) = 1 − α 1 (t)) for both control modes of VIC and VDC.
The first layer of the fuzzy controller is a two-dimensional control with normalization coefficients k 1 , k 2 , and k 3 for the input quantities ∆f i (t) and d∆f i (t)/dt and the output quantity α 1 (t), as shown in Equation (10).
where ∆F(t) is the allowable interval of primary FM, and ∆f imax (t) is the maximum value of frequency deviation.
The Mamdani-type affiliation function is chosen as the affiliation function.∆f i (t) and d∆f i (t)/dt are the two inputs of the fuzzy controller with the theoretical domain range of [-1,1] and α 1 (t) is the output of the fuzzy controller with the theoretical domain range of [0,1].The fuzzy sets are {NB(negative large), NM(negative medium), NS(negative small), ZO(zero), PS(positive small), PM(positive medium), PB(positive large)}.
The control rules of the first layer fuzzy controller are as follows: when d∆f i (t)/dt is larger and ∆f i (t) is smaller, the BESS should increase the participation of the VIC mode to help the grid to quickly suppress the frequency deviation change rate, so α 1 (t) should also increase accordingly; when d∆f i (t)/dt is smaller and ∆f i (t) is larger, the participation of the VDC mode should be increased to suppress the frequency deviation fluctuation to a stable value, so α 1 (t) should also decrease accordingly; when d∆f i (t)/dt and ∆f i (t) are both large, the energy storage equipment should be restored to ∆f i (t) as the primary goal, and α 1 (t) should be increased to help to stabilize the grid frequency fluctuations; when d∆f i (t)/dt and ∆f i (t) are both small, to prevent the frequent operation of the energy storage equipment, α 1 (t) should be taken as a moderate or large value to reduce the operating loss of energy storage when restoring ∆f i (t) at the time of operation loss.Next, the values of the affiliation functions of ∆f i (t), d∆f i (t)/dt, and α 1 (t) are defined as A u1 (t), A u2 (t), and A u3 (t), respectively.Finally, the three-dimensional relations of inputs A u1 (t) and A u2 (t) and output A u3 (t) can be obtained as shown in Figure 4, and the table of fuzzy control rules is shown in Table 2.
increase accordingly; when dΔfi(t)/dt is smaller and Δfi(t) is larger, the participati VDC mode should be increased to suppress the frequency deviation fluctuation t value, so α1(t) should also decrease accordingly; when dΔfi(t)/dt and Δfi(t) are bo the energy storage equipment should be restored to Δfi(t) as the primary goal, should be increased to help to stabilize the grid frequency fluctuations; when and Δfi(t) are both small, to prevent the frequent operation of the energy storag ment, α1(t) should be taken as a moderate or large value to reduce the operatin energy storage when restoring Δfi(t) at the time of operation loss.Next, the valu affiliation functions of Δfi(t), dΔfi(t)/dt, and α1(t) are defined as Au1(t), Au2(t), an respectively.Finally, the three-dimensional relations of inputs Au1(t) and Au2(t) an Au3(t) can be obtained as shown in Figure 4, and the table of fuzzy control rules in Table 2.The output fuzzy quantity Au3(t) is defuzzified using the area center o method, and the final distribution factors α1(t) and α2(t) are obtained as shown in (11).The output fuzzy quantity A u3 (t) is defuzzified using the area center of gravity method, and the final distribution factors α 1 (t) and α 2 (t) are obtained as shown in Equation (11).
where u 1 , u 2 , and u 3 are the values of ∆f i (t), d∆f i (t)/dt, and α 1 (t) after fuzzy quantization, respectively, and A u1 (t), A u2 (t), and A u3 (t) are the values of ∆f i (t), d∆f i (t)/dt, and α 1 (t) after substitution, respectively.
The virtual inertia distribution factor α 1 (t) and the virtual sag distribution factor α 2 (t) obtained from the fuzzy controller can be substituted into Equation ( 9) to obtain the total output force ∆P B for the multiple BESS groups participating in a single FM.

Balanced Control Layer
The optimal output allocation of each BESS is achieved based on the equal consumption micro-increase rate criterion for the overall output of the BESS, as determined by the adaptive regulation layer.The fundamental concept of equalization control can be summed up as follows: to achieve local target consistency, neighboring connected intelligence communicate with each other, and to achieve global target consistency, signals are sent to the control center.The establishing function, parameter initialization, and repeated update are the three components that make up the equilibrium control.Figure 5 depicts the homogeneous control's structure map.
output force ΔPB for the multiple BESS groups participating in a single

Balanced Control Layer
The optimal output allocation of each BESS is achieved based on t tion micro-increase rate criterion for the overall output of the BESS, as adaptive regulation layer.The fundamental concept of equalizatio summed up as follows: to achieve local target consistency, neighborin gence communicate with each other, and to achieve global target cons sent to the control center.The establishing function, parameter initializ update are the three components that make up the equilibrium contro the homogeneous control's structure map.

Objective Function and Constraint Function
The FM loss is the change in the operating cost brought about by th output of the unit in the secondary FM process, and the loss functio BESS is composed of charging and discharging power and charge state the FM loss function of each group of BESS is When PBj,m < 0, PBj,m = P c Bj,m, and BESS is the charging state, and w P d Bj,m, and BESS is the discharging state.The charge state is further expr ing and discharging power in Equation ( 13), and the BESS FM loss Equation ( 14) can be finally obtained after combining it with Equation

Objective Function and Constraint Function
The FM loss is the change in the operating cost brought about by the change in power output of the unit in the secondary FM process, and the loss function of each group of BESS is composed of charging and discharging power and charge state.The m moment of the FM loss function of each group of BESS is (12) where D G,m is the FM loss of each group of BESS at moment m, a Bj and b Bj are the weighting coefficients, Q SOCj,m is the charge state of each group of BESS at moment m, Q ref SOCj is the expected reference value of each group of BESS charge state during FM, Q SOCjmax and Q SOCjmin are the maximum and minimum values of each group of BESS, R Bjmax and R Bjmin are the maximum and minimum values of each group of BESS climbing rate, P Bjmax,m and P Bjmin,m are the maximum and minimum values of each group of BESS FM output, respectively, and ∆t is the preset sampling interval of the timer.
When P Bj,m < 0, P Bj ,m = P c Bj,m , and BESS is the charging state, and when P Bj,m > 0, P Bj,m = P d Bj,m , and BESS is the discharging state.The charge state is further expressed as the charging and discharging power in Equation ( 13), and the BESS FM loss function shown in Equation ( 14) can be finally obtained after combining it with Equation (12). Energies where Q SOCj,m−1 is the charge state of the BESS at m − 1 moment, and η c j and η d j are the BESS charging and discharging efficiency.
In summary, the power balance control objective function and its constraints are

Initialization Settings
The slight increase in consumption λ is the partial derivative of the loss function for power output, and its magnitude can express the FM unit's unit power cost.λ increases as the unit's FM power output increases, and when the optimal power output distribution is achieved, the slight rate of increase in consumption λ of each FM unit tends to be the same.λ is written as follows: The result of the average distribution of the total BESS output ∆P B is used as the initial value of the equalization control, and the initial values of the unit output and λ are as follows: where P 0 Bj,m is the initial value of the FM output of the BESS and λ 0 Bj,m is the initial value of λ for the BESS.

Iterative Update
When iterating over λ, the unit changes its FM output so that its λ is approximately consistent with that of the neighboring storage unit, thus achieving balanced control of the output.At m moment, battery energy storage j is iterated, and the virtual consumption micro-increase rate λ n~j ,m for the nth iteration is obtained by correcting λ n−1 j,m and the FM unit output P n−1 j,m for the n−1st iteration.The correction function is where λ n−1 βd,m is the consumption micro-increase rate of unit β adjacent to unit j, d ∈ [1,D], P 0 j,m is the initial value of the FM output of unit j, and σ 1 and σ 2 are correction factors.
If the virtual consumption micro-increase rate crosses the limit during the iteration, the boundary value of its range is taken as the actual consumption micro-increase rate.The actual consumption micro-increase rate λ n j,m for the nth iteration is where λ max and λ min are the maximum and minimum values of the consumption microincrease rate of unit j, respectively.Substituting λ n j,m into Equation ( 16) gives the theoretical output P n~j ,m of the FM unit, and using the same boundary value constraint gives the actual output P n j,m as P max P n∼ j ,m ≥ P max P min P n∼ j ,m ≤ P min P n≈ j ,m P min ≤ P n∼ j ,m ≤ P max (20) where P max and P min are the maximum and minimum values of unit j FM output, respectively.

Balancing Control Process
The overall flow of the equalization control is as follows, based on the preceding process.The overall flowchart is shown in Figure 6.
Energies 2023, 16, x FOR PEER REVIEW (19), and the updating process requires the neighboring BESSs to exc date their equal consumption micro-increase rates in the process of that the marginal cost of the neighboring BESS is consistent and at equilibrium is reached among the groups of BESSs in the control netw Step 4: The FM power of each group of BESS is updated according to the consumption micro-increase rate λ n j,m, and after substituting the upda sumption micro-increase rate into Equation ( 16), the FM output pow dated in combination with Equation ( 20); when all BESSs update the output according to the equal consumption micro-increase rate consis one action of FM is completed and the whole control network reaches Step 5: Perform the timer's preset sampling interval Δt, and determine whet preset value is reached; if so, end; otherwise, n = n+1; return to Step 3.

Unit parameter initialization
Is the λ of adjacent units consistent?

End
The virtual virtual consumption micro-increase rates λ n~j

Simulation Parameters
The maximum rated capacity of the unit and the rated frequency of 5 as the reference values for the standardization.The analogous model of a t power grid is depicted in Figure 1 and is used to develop a simulation in th Step 1: In the FM process, define the objective function based on the total cost of the BESS and consider the charge state limit and charge/discharge power limit of energy storage as the objective function's constraint function.
Step 2: Set the equivalent consumption micro-increase rate λ 0 Bj,m and the energy storage frequency adjustment power P 0 Bj,m to their starting values, while setting the algorithm's initial iteration number n to 0.
Step 3: Each group of BESS is compared with the equal consumption micro-increase rate of the neighboring BESS and if the consistency condition is satisfied, it means that the storage and the neighboring storage have reached local optimization; otherwise, its equal consumption micro-increase rate is updated according to Equations ( 18) and ( 19), and the updating process requires the neighboring BESSs to exchange and update their equal consumption micro-increase rates in the process of FM control, so that the marginal cost of the neighboring BESS is consistent and at the same time equilibrium is reached among the groups of BESSs in the control network.
Step 4: The FM power of each group of BESS is updated according to the updated equal consumption micro-increase rate λ n j,m , and after substituting the updated equal consumption micro-increase rate into Equation ( 16), the FM output power P n j,m is updated in combination with Equation (20); when all BESSs update the FM power and output according to the equal consumption micro-increase rate consistency criterion, one action of FM is completed and the whole control network reaches stability.
Step 5: Perform the timer's preset sampling interval ∆t, and determine whether the timer's preset value is reached; if so, end; otherwise, n = n+1; return to Step 3.

Simulation Parameters
The maximum rated capacity of the unit and the rated frequency of 50 Hz are used as the reference values for the standardization.The analogous model of a typical regional power grid is depicted in Figure 1 and is used to develop a simulation in the Matlab/Simulink platform.In order to compare this technique (Scheme 3) to the linear variable sag coefficient method (Scheme 2) and no energy storage, two typical situations of step disturbance and continuous disturbance are devised (Scheme 1).The results of this paper (Scheme 3) compared with the methods employed in references [28][29][30] are shown in a table in Section 5.4.The linear variable sag coefficient approach (Scheme 2) mostly refers to references [14,15,18,19,31].The parameters of the energy storage unit are displayed in Table 3 [32], the parameters of the system simulation are displayed in Table 4 [33], and the parameters of the evaluation index used to compare the outcomes are displayed in Table 5.

Step Perturbation
In area i, a 0.01 step perturbation of ∆P Li (standardized value) is added.The change curves in frequency deviation, FM unit output, and battery charge condition of the three schemes under the step perturbation are utilized for comparison in order to more thoroughly validate the efficacy of the approach in this study based on the evaluation system.
The system's frequency deviation change curve under step disturbance is shown in Figure 7a, and the comparison curves of the three schemes can be found there; all three schemes can achieve primary frequency regulation, and since primary frequency regulation is accomplished through differential regulation, Scheme 3 can recover the frequency deviation to a smaller range than Schemes 1 and 2. Scheme 3's frequency drop and recovery speeds are higher than those of Schemes 1 and 2 by 29.45% and 18.26%, respectively.As a result, Scheme 3 can modulate the primary frequency better.
The output power variation curves for the energy storage units under Schemes 2 and 3 are shown in Figure 7b,c, respectively.Figure 7b,c after the step disturbance, can be used to show that the output power of each group of BESS varies depending on their technical characteristics, that the output power of a BESS increases with its capacity, and that a BESS with a capacity that is too large is also compelled to leave FM early due to the charging and discharging power and charging states exceeding the limit.Whereas BESS 4 has a small capacity and a huge power output, BESS 1 has a large capacity and a small power output.Comparatively speaking, it was discovered that the addition of equalization control in Scheme 3 greatly improves and balances the output of each group of BESS, increasing the viability of the long-term operation of energy storage.

Step Perturbation
In area i, a 0.01 step perturbation of ΔPLi (standardized value) is added.The change curves in frequency deviation, FM unit output, and battery charge condition of the three schemes under the step perturbation are utilized for comparison in order to more thoroughly validate the efficacy of the approach in this study based on the evaluation system.
The system's frequency deviation change curve under step disturbance is shown in Figure 7a, and the comparison curves of the three schemes can be found there; all three schemes can achieve primary frequency regulation, and since primary frequency regulation is accomplished through differential regulation, Scheme 3 can recover the frequency deviation to a smaller range than Schemes 1 and 2. Scheme 3's frequency drop and recovery speeds are higher than those of Schemes 1 and 2 by 29.45% and 18.26%, respectively.As a result, Scheme 3 can modulate the primary frequency better.The output power variation curves for the energy storage units under Schemes 2 and 3 are shown in Figure 7b,c, respectively.Figure 7b,c after the step disturbance, can be used to show that the output power of each group of BESS varies depending on their technical characteristics, that the output power of a BESS increases with its capacity, and that a BESS with a capacity that is too large is also compelled to leave FM early due to the charging and discharging power and charging states exceeding the limit.Whereas BESS 4 has a small capacity and a huge power output, BESS 1 has a large capacity and a small power output.Comparatively speaking, it was discovered that the addition of equalization control in Scheme 3 greatly improves and balances the output of each group of BESS, increasing the viability of the long-term operation of energy storage.
The starting charge state of each group of BESS in Figure 7d,e represents the charge state change curves for the energy storage units under Schemes 2 and 3, respectively.The figures show that each group of BESS in Scheme 2 has a significant change in SOC, with the large capacity BESS 1 discharging too much power and causing the SOC to drop quickly, while the small capacity BESS 4 discharges less power and experiences a less pronounced change in SOC, which easily results in the large-capacity BESS being forced to terminate FM early.It was discovered that each group of BESS in Scheme 3 has a balanced and less erratic SOC, and that each group's overall SOC level can be stabilized within the range of 0.415-0.50.This effectively prevents damage to the energy storage caused by overcharging and over-discharging.The starting charge state of each group of BESS in Figure 7d,e represents the charge state change curves for the energy storage units under Schemes 2 and 3, respectively.The figures show that each group of BESS in Scheme 2 has a significant change in SOC, with the large capacity BESS 1 discharging too much power and causing the SOC to drop quickly, while the small capacity BESS 4 discharges less power and experiences a less pronounced change in SOC, which easily results in the large-capacity BESS being forced to terminate FM early.It was discovered that each group of BESS in Scheme 3 has a balanced and less erratic SOC, and that each group's overall SOC level can be stabilized within the range of 0.415-0.50.This effectively prevents damage to the energy storage caused by overcharging and over-discharging.

Continuous Perturbation
In region i, a 40 min continuous perturbation was added, as seen in Figure 8a.The frequency deviation, energy storage output, and change curve in the battery charge state under the step perturbation of the three schemes were used for comparison in order to more thoroughly validate the effectiveness of the approach in this study based on the evaluation system.
The frequency deviation variation curves of the system under continuous disturbance are shown in Figure 8b.The frequency drop rate of Scheme 3 is 18.52% and 9.61% lower than that of Schemes 1 and 2, and the frequency recovery rate is 11.53% and 7.87% higher than that of Schemes 1 and 2. This information can be obtained from the comparison curves of the three schemes.Scheme 3 can control the frequency deviation fluctuation in a smaller range.In conclusion, Scheme 3 has better fluctuation control for frequency differences.
The output variation curves for FM units under Schemes 2 and 3 are shown in Figure 8c,d, respectively.Figure 8c,d show what results can be produced by introducing continuous disturbance: Scheme 2's output of many BESS groups cannot be controlled in a balanced way, each BESS group's output is severely unbalanced, the output of BESS 1 varies more dramatically, and the output of BESS 4 is insufficient.Scheme 3, following the addition of balanced control to the power output of each group of BESS, is balanced after the addition of equalization control, which improves the efficiency and viability of the long-term operation of energy storage.

Continuous Perturbation
In region i, a 40 min continuous perturbation was added, as seen in Figure 8a.The frequency deviation, energy storage output, and change curve in the battery charge state under the step perturbation of the three schemes were used for comparison in order to more thoroughly validate the effectiveness of the approach in this study based on the evaluation system.The frequency deviation variation curves of the system under continuous disturbance are shown in Figure 8b.The frequency drop rate of Scheme 3 is 18.52% and 9.61% lower than that of Schemes 1 and 2, and the frequency recovery rate is 11.53% and 7.87% higher than that of Schemes 1 and 2. This information can be obtained from the comparison curves of the three schemes.Scheme 3 can control the frequency deviation fluctuation in a smaller range.In conclusion, Scheme 3 has better fluctuation control for frequency differences.
The output variation curves for FM units under Schemes 2 and 3 are shown in Figure 8c,d, respectively.Figure 8c,d show what results can be produced by introducing continuous disturbance: Scheme 2's output of many BESS groups cannot be controlled in a balanced way, each BESS group's output is severely unbalanced, the output of BESS 1 varies more dramatically, and the output of BESS 4 is insufficient.Scheme 3, following the addition of balanced control to the power output of each group of BESS, is balanced after the addition of equalization control, which improves the efficiency and viability of the longterm operation of energy storage.
The initial charge state of each set of BESS in Figure 8e,f depicts the charge state change curves for FM units under Schemes 2 and 3, respectively.The SOC changes in each group of BESS in Scheme 2 are fairly extreme: the SOC fluctuation of BESS 4 is too small, and the SOC fluctuation of BESS 1 is too large, which makes it simple to shorten the lifespan of a large-capacity BESS in prolonged use and simple to waste a small-capacity BESS, according to the figure.Comparatively, it was discovered that Scheme 3 can successfully control the SOC variation in each group of BESS within a specific range.
The comparison results of the strategy (Scheme 3) in this paper with Scheme 2 and the methods used in references [28][29][30] are shown in Table 6.After comprehensive comparison and analysis, the following findings were discovered: Scheme 2 lacks the ability The initial charge state of each set of BESS in Figure 8e,f depicts the charge state change curves for FM units under Schemes 2 and 3, respectively.The SOC changes in each group of BESS in Scheme 2 are fairly extreme: the SOC fluctuation of BESS 4 is too small, and the SOC fluctuation of BESS 1 is too large, which makes it simple to shorten the lifespan of a large-capacity BESS in prolonged use and simple to waste a small-capacity BESS, according to the figure.Comparatively, it was discovered that Scheme 3 can successfully control the SOC variation in each group of BESS within a specific range.
The comparison results of the strategy (Scheme 3) in this paper with Scheme 2 and the methods used in references [28][29][30] are shown in Table 6.After comprehensive comparison and analysis, the following findings were discovered: Scheme 2 lacks the ability of adaptive dynamic regulation; so, it is less effective than the other schemes in terms of ∆f m , ∆f rms , V m , V r , Q SOC,ave , and Q SOC,rms ; references [28,29] can realize adaptive dynamic frequency regulation, but lack the consideration of the energy storage charge state, so they are less effective than Scheme 3 in terms of the charge state evaluation parameters Q SOC,ave and Q SOC,rms , meaning they are not as good as that of Scheme 3; and reference [30] can consider the battery charge state based on meeting the grid frequency regulation demand, but the strategy used needs continuous rolling optimization, and the response speed is slow, so the effect of the FM rate evaluation parameters V m and V r is not as good as that of Scheme 3. In summary, Scheme 3 takes into account the charge state constraint of the energy storage while realizing fast adaptive dynamic frequency regulation.Therefore, it has better performance in the integrated level of frequency modulation.

Conclusions
This paper proposes a two-layer control strategy for multiple battery storage systems to participate in grid frequency regulation while taking grid frequency regulation demand and battery frequency regulation capability into account.In comparison to the literature [14,15,18,19,31], the strategy in this paper realizes adaptive switching of two control modes in the adaptive regulation layer by designing a high-precision fuzzy controller, and the frequency drop rate can be reduced from 9.61 to 58.79%, as well as the frequency recovery rate being increased from 7.87 to 29.45%, resulting in a significant improvement in regulation capability and regulation accuracy.The adjustability and accuracy have greatly improved.To achieve the consistency of marginal cost of each group of batteries in the equalization control layer, the equalization control of the energy storage output is based on the criterion of equal consumption micro-increase rate, which has better results in frequency regulation economy and charge state maintenance.

Figure 1 .
Figure 1.Frequency dynamic response model of region i.

Figure 1 .
Figure 1.Frequency dynamic response model of region i.

Figure 3 .
Figure 3. Two-layer control structure in dual-signal mode.

Figure 3 .
Figure 3. Two-layer control structure in dual-signal mode.

Figure 4 .
Figure 4. Three-dimensional relationship between inputs and output.

Figure 4 .
Figure 4. Three-dimensional relationship between inputs and output.

Figure 6 .
Figure 6.Power balance distribution process chart.

Figure 6 .
Figure 6.Power balance distribution process chart.

Figure 7 .
Figure 7. (a) Frequency deviation comparison graph; (b) the output of BESSs for Scheme 2; (c) the output of BESSs for Scheme 3; (d) frequency deviation comparison graph; (e) frequency deviation comparison graph.

Figure 8 .
Figure 8.(a) Continuous load perturbation; (b) frequency deviation comparison graph; (c) the output of BESSs for Scheme 2; (d) the output of BESSs for Scheme 3; (e) battery charge state diagram for Scheme 2; (f) battery charge state diagram for Scheme 3.

Figure 8 .
Figure 8.(a) Continuous load perturbation; (b) frequency deviation comparison graph; (c) the output of BESSs for Scheme 2; (d) the output of BESSs for Scheme 3; (e) battery charge state diagram for Scheme 2; (f) battery charge state diagram for Scheme 3.

Table 1 .
Definition of parameters in the model.

Table 2 .
Fuzzy control rules table.

Table 2 .
Fuzzy control rules table.

Table 3 .
Parameters of energy storage units.