## 2 The Proposed Architecture of the Cyber-Physical Co-Simulation Platform
### Modeling and Control of an Inverter-Based Microgrid  
Figure 2 describes the islanded inverter-based MG structure with its control loops considered in this study; it includes two parallel DGs equipped with their local controllers. Within the islanded inverter-based MG, each DG comprises a DC generation source, a voltage source inverter, an LC filter, and an RL output connector [31]. The modeling of the inverter-based MG, including the primary and secondary control layers, occurred using MATLAB/Simulink. In this work, focusing on the islanded inverter-based MG performance as a cyber-physical system, we simplified the input of the inverter as a DC source [32,33] to prioritize the investigations of real communication infrastructure impacts and cyber-attacks. This purposeful simplification omitted the intricate dynamics of renewable energy sources integrated into the DG system, such as solar variations and wind speed fluctuations, aligning with the proposed research goal and centering focus on the cyber-physical MG assessment. The inverters work under voltage control mode as the system works in an islanded mode, and the voltage and current control loops manage their operation; detailed equations governing these control loops are available in [30,34]. The two parallel-connected inverters operate under a droop control loop for power-sharing. The three mentioned control loops stand for the primary control layer of the MG, as described in Figures 1 and 2. The droop control regulates the system's frequency and voltage by controlling the active and reactive powers [31, 32, 33, 34], standing as the primary level for frequency regulation within each inverter as per the present load conditions. It introduces synthetic droop to derive the reference frequency and voltage while computing the reactive and active output powers, as outlined in [33,34]. The instantaneous values of the active and reactive powers are \(p_{inst}\) and \(q_{inst}\), respectively, as described in (1); \(\
u_{o}^{dq}\) and \(i_{o}^{dq}\) are the inverter output voltage and current after the dq-frame transformation. Subsequently, these instantaneous  
Figure 2: Schematic diagram of an islanded inverter-based microgrid with primary and secondary control loops. values pass through a low-pass filter to calculate the fundamental values of powers \(P\) and \(Q\), as given in (2). \[p_{inst}=v_{o}^{d}v_{o}^{d}+v_{o}^{q}l_{o}^{q} \tag{1}\]  
\[q_{inst}=v_{o}^{q}l_{o}^{d}-v_{o}^{d}l_{o}^{q} \tag{2}\]  
Introducing an artificial droop in the frequency and output voltage of the inverter, as shown in (3), facilitates power-sharing among the sources; \(P_{i}\) and \(Q_{i}\) are the DG's active and reactive output power. \(\omega_{ni}\) and \(V_{ni}\) are the reference signals for the system frequency and voltage, while the desired voltage and frequency are \(v_{o}\), \(n_{mgi}\) and \(\omega_{i}\); \(m_{pi}\) and \(n_{qi}\) are the active and reactive power droop coefficients. \[\omega_{i}=\omega_{ni}-m_{pi}P_{i} \tag{3}\] \[v_{o,magi}=V_{ni}-n_{qi}Q_{i}\]  
We implement centralized secondary control to eliminate the deviations in the system's frequency and voltage from their nominal values during system operation. In this work, the centralized secondary control layer is based on a conventional PI control scheme that receives the frequency value from the primary control layer and restores the deviations in the frequency value, maintaining it at 60 Hz under different operating conditions. This method allows the restoration of voltage value deviation as well. The PI-based centralized secondary controller sends the control signals to restore the frequency and voltage deviations \(\Delta\omega\) and \(\Delta v\), respectively, as given in (4). For the implemented PI-based frequency secondary controller, \(\omega_{ref}\) and \(\omega_{meas}\) are the reference and measured frequency values; \(K_{pf\_sec}\) and \(K_{if\_sec}\) are the proportional and integral gains, respectively.