Hierarchical Control for Islanded Microgrids Based on Adjustable Power Consensus

: For the problem of power allocation in microgrid hierarchical control, a distributed hierarchical control strategy based on consensus algorithm is proposed. When the load suddenly increases, due to the different adjustable power of different distributed generators (DGs), overcharging and discharging of DGs will result if the increased load is not redistributed. The distributed hierarchical control strategy proposed in this paper deﬁnes the proportion between the local increased load and the local adjustable power as the response ratio. With the objective of ensuring that the frequency and voltage of the microgrid can be restored to their rated value, the response ratios of DGs are adjusted by applying the consensus algorithm. Further, the microgrid realizes the reasonable operation of the microgrid by dynamically distributing the increased load in real time. Finally, the feasibility and effectiveness of the proposed strategy is veriﬁed by analyzing the stability of the system and building a microgrid simulation model in the Matlab/Simulink simulation platform.


Introduction
With the consumption of non-renewable energy and environmental pollution, the global energy crisis is becoming more and more severe [1], and the efficient use of new energy sources has become the trend of social development [2]. Microgrids can make the penetration of renewable energy in the large grid increase, and also improve the power quality and reliability of power supply [3]. Microgrids are mainly composed of distributed generators, energy storage devices, loads, etc., and usually have two working modes: grid-connected and islanding operation. The stable operation of microgrids requires effective and rational control technology, so researchers have paid close attention to this area [4].
In the development of the power system, two control schemes, distributed and centralized, were proposed [5]. Centralized control requires each DG to exchange information with the central controller, the central controller issues commands, and the local control receives the information to be able to make actions, each DG only needs to communicate with the central controller, while no communication is required between the neighbors of the DG [6]. Distributed control requires only local information to be obtained via sparse communication between neighbors for calculation and analysis, and DGs make decisions based on the calculation results to optimize and control the entire grid. Centralized control is prone to face problems such as large computation, single point of failure, and poor scalability, compared to distributed control which has better economy and robustness [7], and has been intensively studied by many scholars recently.
The choice of control structure is important for the stable operation of microgrids, and nowadays, the control and optimization of the grid is mainly achieved by means of hierarchical control [8]. Microgrids are usually divided into three levels of control structure, primary control, secondary control, and tertiary control. Generally, they have 1.
Introducing intermediate voltage control in the secondary control to compromise the conflicts between voltage regulation and reactive power sharing caused by line impedance mismatch and integrating the primary, secondary and tertiary control of the microgrid in one framework.

2.
Introducing response ratio in the tertiary control to coordinate the rational operation of the microgrid. The leader-following consensus algorithm makes the response ratio of different DGs consistent, which can greatly save communication cost and improve the robustness of the system. 3.
By dynamically responding to the changes of load to make real-time power distribution in tertiary control, it can not only meet the stability of system frequency and voltage but also realize the accurate distribution of active power and reactive power under the premise of being able to attain the control target.

Consensus Algorithm
With the development of MAS, which provides theoretical support for the development of distributed system of microgrid, each DG in the microgrid can be treated as a multi-agent, and each DG cannot access the entire information, but can exchange information with its neighbors. A MAS theory with a leader is used to maintain the voltage and frequency of DGs at the rated value. The leader is a single individual, which can be either virtual or real. All the agents will approach the state of the leader and eventually reach the same state as the leader.
The communication structure within the network of MAS can be represented by graph G, where the agents can be considered as nodes of the graph, and the communication lines connecting two nodes can be considered as edges of the graph. The graph G can be represented by G = (V, ε, A), where V = {ν 1 , ν 2 , · · · , ν n } is the set of agents, ε is the set of edges, and the relationship between neighboring agent is represented by the adjacency matrix A = a ij n×n . a ij denotes the communication weight between each agent, if there is communication between agent i and agent j, then a ij > 0, otherwise a ij = 0. N i denotes the set of the neighbors of the agent i. For a MAS with a leader, a diagonal matrix β = [g 1 , g 2 , . . . , g n ] (navigator matrix) is also defined, if there is communication between agent and leader, then g i = 1, otherwise g i = 0. The consensus algorithm with leader is generally used to solve two problems, the first one is the consensus problem between neighboring agents and the other one is the tracking problem between agents and leader. The control laws shown in (1) are generally used to solve these two problems: where a ij is the element in the adjacency matrix, g i is the element in the leader matrix, and x 0 is the state of the leader. When the communication topology graph of the MAS contains a directed spanning tree, the system will reach its final stability, so that each agent will reach the same state as the leader. The leader can be a given value predetermined in advance or a dynamically changing reference value.

Hierarchical Control Strategy Based on Adjustable Power Consensus
Traditional centralized control has been hard to meet the needs of microgrid systems with increasingly complex structures and large data volumes due to the increasing scale of microgrid. With the continuous development of multi-intelligent body systems, people start to use distributed control based on multi-intelligent body systems to solve problems that cannot be easily handled in centralized control, such as large data scale, many targets, and "plug-and-play". In order to realize the overall control of microgrid, this paper proposes a hierarchical distributed control strategy based on the consensus algorithm of multi-intelligent body system with the premise of ensuring the reasonable output of each DG. The control structure is shown in Figure 1.
In order to coordinate the microgrid, the control strategy is divided into three layers. The primary control is the droop control, which regulates the output power of the inverter according to the droop curve. The second control is the deviation regulation layer. Firstly, the voltage and frequency compensation values are calculated by the leader-following consensus algorithm to maintain the stability of the voltage and frequency of the microgrid system, and then the power compensation values are calculated by the common consensus algorithm to realize the accurate power distribution according to the droop coefficient. The tertiary control is the dynamic power distribution layer, and the new droop coefficient is obtained by the leader-following consensus algorithm to make the adjustable power of DGs achieve consensus. In order to coordinate the microgrid, the control strategy is divided into three layers. The primary control is the droop control, which regulates the output power of the inverter according to the droop curve. The second control is the deviation regulation layer. Firstly, the voltage and frequency compensation values are calculated by the leader-following consensus algorithm to maintain the stability of the voltage and frequency of the microgrid system, and then the power compensation values are calculated by the common consensus algorithm to realize the accurate power distribution according to the droop coefficient. The tertiary control is the dynamic power distribution layer, and the new droop coefficient is obtained by the leader-following consensus algorithm to make the adjustable power of DGs achieve consensus.

Primary Control
Droop control is to regulate the active and reactive power output of the inverter by

Primary Control
Droop control is to regulate the active and reactive power output of the inverter by changing the frequency and voltage of the inverter output by simulating the droop external characteristics of the synchronous generator. The control equation of droop control is shown in (2). Where ω 0 , ν 0 is the rated frequency and voltage of the inverter, m i , n i is the droop coefficient of active power and reactive power, ω i , υ i , p i , q i is the frequency, voltage, active power and reactive power output of the ith inverter, respectively, and P * i , q * i are the rated active power and reactive power of the ith inverter.

Deviation Control Based on Consensus Algorithm
(1) Frequency-Active power In the conventional droop control, it can be derived from Equation (2) that when the active power is not the rated value, it makes the frequency of the inverter deviate. Therefore, in the secondary control of the microgrid, the first control objective is to achieve frequency recovery. However, during the recovery of the frequency, since the compensation value of each DG will be different every time, which leads to differences in the transient frequency of each node. The differences can destroy the active power distribution achieved in the primary control based on the droop coefficient. In order to keep the original active power distribution constant, i.e., to keep Equation (3) valid, the second control target of secondary control, power distribution, is introduced.
In order to achieve both frequency recovery and active power distribution at the same time, the following control scheme is used. the secondary control equation of P-W is shown below where ω ni is the variable reference frequency factor.
where λ ωi is the frequency compensation factor and λ pi is the active power compensation factor.
Equation (6) not only achieves frequency consensus among different agents through the communication network, but also completes the tracking of the virtual leader frequency. Equation (7) is used to synchronize each DG by the agent consensus algorithm to compensate for the active power distribution mismatch caused by the different values of transient frequency compensation. Where a ij is the communication weight factor, g i is the drafting gain, and when the node i is the drafting point, g i = 1, otherwise g i = 0. ω re f is the reference frequency, c w , c p is a positive gain coefficient.
Where e ωi is the tracking error of the frequency .
The matrix expression for the frequency tracking error is derived from (9) .
of which e ω = [e ω1 , e ω2 , . . . , Theorem 1. Graph G possesses a spanning tree and has at least one root node, i.e., g i = 0. Let Where ω i is an element in vector ω and satisfies Aω = 1, Let A = G + L. It is possible to conclude that Q = PA + A T P is positive definite. Consider the Lyapunov candidate function as Derivation of V: From Theorem 1, we know that PA + A T P is positive definite, and it follows that . V < 0. Thus it can be obtained that lim t→∞ ω i = ω re f , and finally the frequencies of all DGs will converge to the frequency reference value.
Defining active power tracking error p is the active power at steady state Rewritten in matrix form . e p = −c p Le p (16) of which e p = [e p1 , e p2 , . . . , e pn ], Consider the Lyapunov candidate function as Similarly, it can be proved that, let L = A, can be obtained at the time of system stability, satisfying m 1 p 1 = m 2 p 2 = · · · = m i p i , i.e., the active power of the microgrid is distributed according to the droop factor.
(2) Voltage-Reactive power Because the line impedance mismatch will lead to a conflict between the voltage consensus of DG and the reactive power sharing of DG, it will prevent them from being achieved simultaneously. Furthermore, the use of virtual impedance can only weaken but not completely eliminate the deviation due to impedance. Therefore, transforming the inverter output voltage consensus originally controlled into controlling the inverter intermediate voltage consensus, where the intermediate voltage is defined as shown in (19), will be able to avoid such a conflict. Thus, transforming the control objective to achieve precise control of the voltage at the PCC and the accurate reactive power sharing.
To achieve these two control objectives a control scheme is designed as shown in (18): In order to achieve precise control of the voltage at the PCC and equalization of reactive power, an intermediate voltage E i , which is represented as shown in (19), is chosen between the inverters. Where λ Ei and λ qi are the intermediate voltage compensation factor and reactive power compensation factor, respectively. The intermediate voltage compensation factor is shown in (20) dλ Ei dt where c E is a positive gain coefficient and E re f is the reference value of the intermediate voltage, which is set so that the voltage at the PCC can be accurately recovered to the given reference value. The reference voltage is designed as shown in (21). Where U o is generally set as the rated voltage, k p and k i is the proportional and integral coefficients of the PI controller, respectively, and U * PCC is the reference voltage at PCC. The difference between the reference value at PCC and the actual value is calculated by the PI controller and then summed with U 0 to generate the voltage reference value. When the output voltage of the inverter achieves tracking of the reference voltage under the control of the consensus algorithm, it can simultaneously achieve the tracking of the voltage at PCC to its reference voltage.
The reactive power compensation factor is shown in (22) where c q is the positive gain coefficient and Equation (22) is mainly used to keep Equation (23) valid for accurate reactive power sharing.
Defining the voltage tracking error .
Rewritten in matrix form where q is the reactive power at steady state Similarly it can be shown that at system stability, lim t→∞ E i = E re f and n 1 q 1 = n 2 q 2 = · · · = n i q i can hold, indicating that the intermediate voltage can be restored to the reference voltage and the reactive power can be distributed according to the reactive droop coefficient.

Power Control Based on Dynamic Adjustable Power Consensus
When the load suddenly increases, the maximum power of each DG is different, and the adjustable power is also different. If the power is not reasonably distributed, it may appear that some DGs have reached the maximum power output, while another DGs are working in a lower output state. In this case, on the one hand, it is impossible to respond to the load demand in time, on the other hand, the usage time and efficiency of the small-capacity DGs will also be affected, which may lead to the overuse of the DGs and cause unnecessary losses. Therefore, in the distributed control strategy proposed in this paper, the distributed algorithm is used to make the microgrid work at the optimum point according to the adjustable power of DG to respond to the change of the load when the load changes.
Let the maximum power of each DG be p maxi , defining the active power that can be adjusted by each DG be P resi , can be derived: The total active adjustable quantity p rest can also be obtained as follows: when the load increases p t , each DG increases its output ∆p i , where it can be derived that The response ratio of different DGs is defined as α i , whose expression is shown in (33), and is used to represent the ratio of the response of DGs to load changes and its adjustable active power.
when redistributing the active power, in order to let the DG with a large adjustable active power take as much of the load variation as possible, the response ratio of each DG has to be controlled to be consistent. This is so that the increased load will be distributed according to the adjustable active power of each DG. To achieve this control objective, a control scheme as shown in (34) is used.
where c α is a gain coefficient, α re f is the leader of the response ratio, calculated by (35), and represents the ratio of the total load increase to the total adjustable active power. Define the tracking error of the corresponding ratio .
Rewritten in matrix form of which e α = [e α1 , e α2 , . . . , e αn ], c E = diag[c α1 , c α2 , . . . , c αn ]. The proof process is similar to the above, and at steady state lim t→∞ α i = α re f , i.e., the response ratio of each DG can be controlled to the reference response ratio. After the new response ratio is calculated by the consensus algorithm, the active response power p add of each DG is calculated by (39), which is then summed with the previous output power p i to obtain the output power p i after the load increase, as shown in (40).
p add = α i * p resi (39) Finally the corrected droop coefficient can be calculated by (21), where c is a fixed constant Similarly the corrected droop coefficient n i can be obtained The new droop coefficient is sent to the primary control to achieve a reasonable distribution of power. The hierarchical control structure is shown in Figure 2.

Simulation Analysis
To verify the effectiveness of the proposed hierarchical distributed control, the simulation model is built on MATLAB/Simulink simulation platform. The framework of the microgrid is shown in Figure 3, four DGs are used, the communication in DG is shown in Figure 3, the rated voltage of the system is 380 V and the frequency is 50 Hz, the parameters of DG capacity, load and line impedance are shown in Table 1.

Simulation Analysis
To verify the effectiveness of the proposed hierarchical distributed control, the simulation model is built on MATLAB/Simulink simulation platform. The framework of the microgrid is shown in Figure 3, four DGs are used, the communication in DG is shown in Figure 3, the rated voltage of the system is 380 V and the frequency is 50 Hz, the parameters of DG capacity, load and line impedance are shown in Table 1.

Simulation Analysis
To verify the effectiveness of the proposed hierarchical distributed control, the simulation model is built on MATLAB/Simulink simulation platform. The framework of the microgrid is shown in Figure 3, four DGs are used, the communication in DG is shown in Figure 3, the rated voltage of the system is 380 V and the frequency is 50 Hz, the parameters of DG capacity, load and line impedance are shown in Table 1.  First, the first and second layers of the system are verified to see if the recovery of system frequency and voltage can be achieved. At 0 s the system starts with load and the rated power ratio of DG is DG1:DG2:DG3:DG4 = 3:4:4:3 and the initial load of the system is 28 KW + j28 KVar, at 0.5 s the load is increased by 14 KW + j14 KVar.  First, the first and second layers of the system are verified to see if the recovery of system frequency and voltage can be achieved. At 0 s the system starts with load and the rated power ratio of DG is DG1:DG2:DG3:DG4 = 3:4:4:3 and the initial load of the system is 28 KW + j28 KVar, at 0.5 s the load is increased by 14 KW + j14 KVar. Figure 4a shows that at the start of the system, there is an initial drop in frequency due to starting with load, but it is able to recover to 50 Hz and remain stable in about 0. The simulation set the power distribution ratio to DG1:DG2:DG3:DG4 = 3:4:4:3. From Figure 5a,b we can see that the active power distributed by each DG is 6 KW, 8 KW, 8 KW, 6 KW respectively, and the reactive power is the same. The load increases at 0.5 s and the same accurate distribution of active and reactive power are achieved. Figure 5c shows the mp consensus achieved with the introduction of the active power compensation factor, where a sudden increase in load at 0.5 s causes the mp to increase and reach a new steady state value. Figure 5d shows the nq consensus of reactive power with the same transformation process as active power.  The simulation set the power distribution ratio to DG1:DG2:DG3:DG4 = 3:4:4 Figure 5a,b we can see that the active power distributed by each DG is 6 KW, 8 KW 6 KW respectively, and the reactive power is the same. The load increases at 0.5 s same accurate distribution of active and reactive power are achieved. Figure 5c sh mp consensus achieved with the introduction of the active power compensatio where a sudden increase in load at 0.5 s causes the mp to increase and reach a new state value. Figure 5d shows the nq consensus of reactive power with the same t mation process as active power. The system is then verified after adding the tertiary layer of control, which is mainly designed to respond to load changes and distribute the increased load by the response ratio α i when the load increases. Figure 6 shows that the system is running steadily before 0.5 s and the active power allocated by DG1-4 are 6 KW 8 KW, 8 KW, 6 KW respectively. At 0.5 s the system increases load 14 KW + j14 kvar. At this time setting, the maximum output power is DG1-4 to16 kw, 16 KW, 12 KW, 12 KW, so at this time, the more adjustable power of DG1 should bear an increased load, and the less adjustable power of DG3 should bear less of an increased load. The response ratio is calculated to allocate the increased load, and the response of DG1-4 to the increased load is 5 KW, 4 KW, 2 KW, 3 KW respectively, and the final power allocated by DG1-4 should be 11 KW, 12 KW, 10 KW, 9 KW. Figure 6b shows the change process of reactive power, which is the same as the change process of active power.
increased load, and the less adjustable power of DG3 should bear less of an increased load The response ratio is calculated to allocate the increased load, and the response of DG1to the increased load is 5 KW, 4 KW, 2 KW, 3 KW respectively, and the final power allo cated by DG1-4 should be 11 KW, 12 KW, 10 KW, 9 KW. Figure 6b shows the chang process of reactive power, which is the same as the change process of active power.   Figure 7a,b show the variation process of the frequency and the voltage at PCC afte the system is added to the tertiary control. Frequency and voltage are both stable after a brief oscillation. Figure 7c shows the course of the intermediate voltage.   Figure 7a,b show the variation process of the frequency and the voltage at PCC after the system is added to the tertiary control. Frequency and voltage are both stable after a brief oscillation. Figure 7c shows the course of the intermediate voltage.

Conclusions
A hierarchical control strategy for microgrid based on adjustable power consensus is proposed by this paper by using distributed cooperative control. The conflict between voltage recovery and reactive power distribution due to line impedance mismatch is

Conclusions
A hierarchical control strategy for microgrid based on adjustable power consensus is proposed by this paper by using distributed cooperative control. The conflict between voltage recovery and reactive power distribution due to line impedance mismatch is solved by using intermediate voltage in the secondary control. Compared with the traditional hierarchical control, the proposed hierarchical control strategy dynamically responds to the load by adjusting the adjustable power in real time in the tertiary control, and it not only recovers the frequency and voltage at PCC, but also ensures the accurate control of active and reactive power in the process of dynamic response and finally realizes the reasonable operation of the microgrid. The proposed control strategy is verified in MATLAB/Simulink simulation platform, and all agents are able to work in coordination to achieve control objectives.
Hierarchical control needs the support from communication networks and communication delay is an unavoidable problem in signal transmission process. Communication delay can impair the dynamic performance of the system, reduce the system stability margin, and even result in an unstable system. Therefore, the delay compensation method can be further studied. Additionally, considering the event triggering mechanism to further reduce the communication of the system is also the subsequent work of this paper.

Data Availability Statement:
The data that support the findings of this study are included within the article.

Conflicts of Interest:
The authors declare no conflict of interest.