## 3 Hierarchical Frequency Control Scheme
### Finite-Time Consensus Control Algorithm  
Considering the communication between the coordinated control layer and individual demand layer, the communication network of numerous ACs can be depicted as a directed graph \(G=(V,E)\), which contains a sequence of nodes \(V=\{v_{1},v_{2},\cdots,v_{N}\}\) and a sequence of edges \(E=V\times V\). In the directed graph, communication links are unidirectional, which means \((v_{m},v_{n})\in E\Rightarrow(v_{n},v_{m})\
otin E\). Thus, an adjacency matrix \(L_{A}=[a_{mn}]\) can be obtained as follows:  
\[a_{mn}=\left\{\begin{array}{l}1,\;if(v_{m},v_{n})\in E\\ 0,\;if(v_{m},v_{n})\
otin E\end{array}\right. \tag{24}\]  
where \(a_{mn}\) denotes the adjacent state of the non-root node.  
Note that in the hierarchical control framework, the control signals are transmitted from the virtual leader of numerous ACs to individual ACs, whereby the virtual pinner serves as the root node in the communication. Thus, the matrix \(L_{R}=[r_{m}]\) can be calculated as follows:  
\[r_{m}=\left\{\begin{array}{l}1,\;if(v_{m},v_{0})\in E\\ 0,\;if(v_{m},v_{0})\
otin E\end{array}\right. \tag{25}\]  
where \(r_{m}\) denote the adjacent state of the root node.  
Based on the mathematical property of the adjacency matrix [16], the convergence of the communication graph can be ensured by the property that there exists a root node in the communication graph and all the eigenvalues of the matrix \(L_{A}+L_{R}\) have the positive real parts.  
In the individual demand layer, a distributed pinning consensus algorithm is proposed to control each individual \(AC\) for fair participation in the secondary frequency control. That requires the power output of all individual ACs to be normalized and the power rating \(p_{j}(t)\) of the \(AC\) system to be introduced as follows:  
\[P_{e,j}(t)=p_{j}(t)\cdot P_{ACS,j}^{\max} \tag{26}\]  
where \(P_{ACS,j}^{\max}\) is the maximum power of the \(j\)th inverter AC, \(p_{j}(t)\) refers to power state of the \(j\)th \(AC\) at \(t\)th period.  
According to the proposed virtual battery model in section II, the dynamic characteristics of the AC system can be established. In comparison with the first-order power equation in [26], the second-order different equation is proposed to describe the state of charge of AC system. Thus, the SOC of AC system can be formulated as follow:  
\[soc_{j}(t)=soc_{j}(0)-\frac{1}{3600}\int\limits_{t=0}^{T}\frac{dso_{j}(t)}{ dt} \tag{27}\]  
The corresponding the energy state \(e_{j}(t)\) can be set equal to the \(SOC\) state and the dynamic characteristic of individual \(AC\) can be reformulated as follows:  
\[\left\{\begin{array}{l}\frac{de_{j}(t)}{dt}=-\frac{e_{j}(t)}{RC}+\frac{k_{p} }{k_{q}R(T_{max}-T_{min})}P_{e,j}+\frac{soc_{j}(0)}{RC}\\ \frac{dP_{e,j}(t)}{dt}=u_{j}(t)\end{array}\right. \tag{28}\]where \(e_{j}(t)\) denotes energy state of the \(j\)th \(AC\) at \(t\)th period, \(u_{j}(t)\) is control signal of the \(j\)th \(AC\).  
Meanwhile, the reference values of the power state and the energy state can be updated by the distributed pinner in real-time, which serves as the virtual leader of the communication graph:  
\[\left\{\begin{array}{l}\frac{d\omega_{0}(t)}{dt}=-\frac{\omega_{0}(t)}{RC}+ \frac{k_{p}}{k_{q}R(T_{\max}-T_{\min})}P_{e,0}+\frac{\mathrm{soc}_{0}(0)}{RC} \\ P_{e,0}(t)=\frac{\mathrm{AP}_{AC}}{\sum\limits_{i=1}^{\infty}P_{ACS,j}^{\max}} \end{array}\right. \tag{29}\]  
In comparison with conventional consensus algorithms, the finite-time approach is developed to ensure the convergence of the energy state and the power tracking in the individual demand layer:  
\[\begin{array}{ll}u_{j}(t)=&\sum\limits_{k=1}^{N_{AC}}\left(a_{jk}sg\left(e _{j}(t)-e_{k}(t)\right)^{\chi}-r_{j}sg\left(e_{j}(t)-e_{0}(t)\right)^{\chi} \right)\\ &-\kappa\sum\limits_{k=1}^{N_{AC}}\left(a_{jk}sg\left(p_{j}(t)-p_{k}(t) \right)^{\phi}-r_{j}sg\left(p_{j}(t)-p_{0}(t)\right)^{\phi}\right)\end{array} \tag{30}\]  
where \(\kappa,\phi,\chi\) denote auxiliary variables in the consensus protocol.