## 2 Transient Stability Assessment by Co-Simulation
### Overview of mosaik Architecture  
mosaik is a robust scenario specification framework that can integrate many simulators. It is a flexible Python-based open-source co-simulation framework with the capability of generating a large scale scenario, quantifying uncertainty and developing multi-agent systems [40; 41; 42]. There are several references showing the application of mosaik in, for example, cyber-physical energy systems [43], urban energy analysis [44], and grid monitoring [45]. A peak-shaving algorithm is implemented to improve the voltage stability of a distribution network in [46].  
The system architecture of mosaik consists of a core framework and a set of adapters [43], as is shown in Figure 2. The core includes interconnecting modules such as the sim-manager and the scheduler. A scenario script is written by the user that specifies the model parameters and the sequence of the execution of the simulators. The scenario-API establishes the interface between mosaik and the scenario script. Based on the scenario, the scheduler defines the data exchange order as the simulations need to be executed and exchange data between each other. Therefore, the scheduler is the synchronization unit of mosaik. The situation that one simulator needs data from another simulator and vice versa is called a cyclic data flow. The scheduler applies a directed acyclic schedule graph and handles this situation. The sim-manager is responsible for handling the simulator process and the communication between them. The component-API enables one to interface a  
Figure 1: The monolithic (**left**) and co-simulation (**right**) transient stability simulation steps.  
wide range of simulators such as the MATLAB-API and the FMI adapter [43]. The FMI adapter facilitates the connection of different FMUs with the mosaik framework, which is considered a key enabler for modular transient stability simulations.  
The concept of different components that synchronise with one another is one of the critical characteristics of co-simulations [47]. A proper synchronization mechanism ensures the proper progress of the simulation time and data exchange between simulators [46]. It can mainly be divided into (i) event-driven synchronization [48], and (ii) time-stepped synchronization [49]. The simulation time in the time-stepped synchronization method progresses continuously. Therefore, it is more beneficial for a system consisting of differential equations [50]. In the time-stepped method, the time intervals are predefined, and simulators run independently up to the fixed synchronization points. Then, the simulators will wait and exchange information with other simulators. However, this method is not suitable for time-critical applications that require numerous interfacing connections and instants between simulators. Thus far, event-based synchronization is the most common synchronization method [24]. The synchronization method in mosaik is also based on an event-based method. All time steps and systemic occurrences within the power system simulator and controller are considered as an event in the event list shown in Figure 3a. Figure 3b shows the mosaik synchronization steps. After initialisation, first, the power system simulator is advanced from \(t_{1}\) to \(t_{2}\), then pauses. The power system simulation data are transmitted to the converter controller so that it can proceed its steps. The controller simulator advances till \(t_{2}\), and then data are exchanged from the controller to the power system simulator. Now, the power system can advance the calculation to \(t_{3}\) and so forth. This process is repeated until the end of the simulation time defined in the scenario.  
Figure 2: The mosaik structure [43].