Noname manuscript No. (will be inserted by the editor)
Smart Grid Co-Simulation with MOSAIK and HLA: A Comparison Study
C. Steinbrink · A. A. van der Meer · M. Cvetkovic · D. Babazadeh · S. Rohjans · P. Palensky · S. Lehnhoff
Received: date / Accepted: date
Abstract Evaluating new technological developments 1 Introduction for energy systems is becoming more and more com- plex. The overall application environment is a contin- The evaluation of new planning, operation and control uously growing and interconnected cyber-physical sys- designs in the energy domain requires thorough anal- tem so that analytical assessment is practically impos- ysis. In the recent years, the overall character of the sible to realize. Consequently, new solutions must be domain has turned to the field of cyber-physical energy evaluated in simulation studies. Due to the interdisci- systems (CPES) with smart grids as one of its most plinarity of the simulation scenarios, various heteroge- prominent concepts. This development leads to com- neous tools must be connected. This approach is known plex, interdisciplinary setups that are infeasible to han- as co-simulation. During the last years, different ap- dle with purely analytical evaluation. Since testing new proaches have been developed or adapted for applica- approaches in laboratories or in the field is too inflex- tion in energy systems. In this paper, two co-simulation ible and expensive for early development stages, it is approaches are compared that follow generic, versatile an established procedure to conduct co-simulation be- concepts. The tool mosaik, which has been explicitly forehand. This technique is defined as the coordinated developed for the purpose of co-simulation in complex execution of two or more simulation models that dif- energy systems, is compared to the High Level Archi- fer in their representation as well as in their runtime tecture (HLA), which possesses a domain-independent environment [16]. scope but is often employed in the energy domain. The The first co-simulation implementations have mostly comparison is twofold, considering the tools’ concep- been focused on analysis of the interaction between tual architectures as well as results from the simulation power system and communication network simulation of representative test cases. It suggests that mosaik models [8,7,6,10]. However, besides this direct coupling may be the better choice for entry-level, prototypical of two tools, more generic co-simulation approaches have co-simulation while HLA is more suited for complex been developed during the last years. They are called and extensive studies. co-simulation frameworks because one of their integral parts is a middleware that is responsible for data ex- C. Steinbrink, D. Babazadeh, S. Lehnhoff change and temporal synchronization of several simula- OFFIS – Institute for Information Technology tion models. Many prominent examples for such frame- Oldenburg, Germany works are either based on the Ptolemy II software E-mail: name@offis.de [13] (e. g. the Building Controls Virtual Test Bed [19]) A. A. van der Meer, M. Cvetkovic, P. Palensky or on various implementations of the High-Level Archi- Delft University of Technology Delft, The Netherlands tecture standard (HLA) for distributed simulation sys- E-mail: [email protected] tems [4] (e. g. C2WT-TE [11]). A rather new example S. Rohjans for a CPES co-simulation framework is the tool mosaik Hamburg University of Applied Sciences that has been developed at the Oldenburg Institute for Hamburg, Germany Information Technology, OFFIS [18,14]. In contrast to E-mail: [email protected] Ptolemy- or HLA-based systems, it features a more con- 2 C. Steinbrink et al. cise set of functionalities, and is aimed at being easy to simulation. Their specific designs are reviewed in the apply for users from different domains. following. Due to the complex character of co-simulation frame- works, it can be difficult for CPES researchers to as- sess which tool suits their needs. This paper is aimed 2.1 mosaik at facilitating this task via a thorough comparison of mosaik, as a light-weight tool on the one hand, and The mosaik framework has been designed specifically an implementation of HLA, as a representation of the for CPES/smart grid research with a special focus on popular standard on the other hand. This comparison the flexible creation of large-scale system configurations is based on both, the particular architectural concepts that may serve for testing of control strategies [17]. of the tools as well as results from a simulation study The architecture of mosaik consists of a simula- implementing a representative CPES setup. tor management module (sim-manager) and a sched- The remainder of this paper is structured as fol- uler. The sim-manager enables data exchange with sim- lows: Section 2 features a discussion of co-simulation in ulators by establishing TCP connections with them. CPES in general as well as mosaik and HLA in partic- The scheduler, on the other hand, coordinates the ex- ular. The conceptual tool comparison is conducted in change of data between all connected simulators based Section 3, followed by the co-simulation study described on a common simulation clock. In its current state, the in Section 4. Section 5, finally, concludes the paper. scheduler provides discretely-timed, explicit simulator coupling. The mosaik system is completed by two APIs for 2 Co-Simulation in Cyber Physical Energy user interaction: the Component-API and the Scenario- Systems API. The Component-API has to be implemented for each simulator that is connected to mosaik. It sets up a Co-simulation in CPES is a complex topic that involves TCP socket and organizes the data exchange with mo- various aspects. A comprehensive overview of the fun- saik in the JSON format. Various versions of the API damental concepts is provided in [12]. Some of the most are available for different programming languages like basic concepts are summarized in the following. Java, Python, or MATLAB. This way, model develop- A co-simulation setup typically consists of indepen- ers may implement the interface in the language that dently executable simulators that represent the differ- is most suitable for their simulator. The implementa- ent components of the simulated system. Furthermore, tion itself is conducted by providing a meta description interfaces are implemented that connect the simulators for the simulator: a high-level description of the pro- to the framework, as well as a middleware that orga- vided simulation models as well as their variables. Fur- nizes the communication between the simulators. This thermore, a small number of interface functions have middleware can either include a so-called master algo- to be implemented that are used by mosaik to control rithm that organizes the complete co-simulation process the simulator. Note that non-simulator components like – or only a set of communication services so that the co- database or data analysis systems may be integrated simulation process emerges from the interaction of the into mosaik using the same API. A mapping between simulators. The temporal synchronization of simulators the Component-API and FMI also allows the integra- may either be realized in an iterative manner or non- tion of FMUs into mosaik co-simulation [15], [9]. iteratively (explicitly). Since CPES co-simulation often The Scenario-API, finally, provides a set of com- involves closed source and other black box simulators, mands that allows users to instantiate model entities explicit coupling schemes are usually more widely ap- from the integrated simulators and establish connec- plied. In these schemes, simulators are either handled tions between them. The mosaik user is to employ one after the other (serial) or in parallel. these functions in a scenario script that may then be Since CPES co-simulation involves various differ- executed to run the co-simulation process. ent research domains, the demand for standardization is high, especially for the interfacing of simulators. A popular standard is the Functional Mock-up Interface 2.2 High Level Architecture (FMI) [3] that allows embedding of simulators in so- called Functional Mock-up Units (FMU). Due to the HLA is a general-purpose architecture for distributed standard’s popularity, it is supported by several tools simulation. It has been developed in the mid-nineties as well as specifically designed toolboxes (e. g. [20]) following an initiative of the United States Department Mosaik and HLA, the tools discussed in this pa- of Defense for the purpose of combat simulation cou- per, both follow the presented understanding of co- pling [5]. The first standardization of HLA came in the Comparison Study – mosaik and HLA 3 year 2000 when IEEE declared it as the IEEE stan- subsystems is managed by a central instance: the RTI dard 1516 for modeling and simulation [1]. Since then, in HLA on the one hand, and mosaiks software core on the HLA capabilities have been expanded. Its current the other hand, consisting of the sim-manager and the version can be found under the IEEE standard 1516.2- scheduler. Furthermore, the communication between the 2010 [2]. RTI and the federates is handled via a number of stan- HLA has been designed for coupling of highly au- dardized function calls, similar to the connection be- tonomous simulators while giving ample control to the tween mosaik and its simulators. user. Using the HLA terminology, these simulators are Aside from these architectural similarities, however, referred to as federates while the entire co-simulation HLA and mosaik imply workflows of different nature setup is referred to as a federation. The communica- for their users. There are typically two types of tasks tion between federates is realized via a message-bus, a user may assume when working with a co-simulation the so-called Runtime Infrastructure (RTI). Through environment. The first one is the integration of a new seven groups of services, HLA provides synchroniza- component into the environment. The second one is the tion of federates and message passing via the RTI. For creation of a co-simulation study employing the already description of the exchanged data, HLA demands the integrated components. Both of these tasks require dif- specification of Simulation Object Models (SOM) on the ferent specification and implementation work in HLA federate level and a Federation Object Model (FOM) and mosaik. on the federation level. These structures are defined us- Integration of new simulators into mosaik requires, ing the Object Model Template (OMT). Finally, HLA as mentioned before, implementation of the Component- specifies a set of ten design rules for the creation of API. This involves the specification of the meta descrip- federations (rules 1 to 5) and federates (rules 6 to 10). tion and the implementation of interface functions. For The synchronization of the entire federation depends integration of new federates into HLA, on the other on the combination of the particular synchronization hand, a SOM has to be specified and a so-called federate mechanisms provided by its federates. Thus, various ambassador implemented that employs RTI services. synchronization mechanisms can be implemented with Mosaik’s meta description is a very high-level simu- the proper invocation of HLA services, some of which lator representation that simply specifies the simulation will be tested later in this paper. models that may be instantiated from the simulator, HLA is capable of synchronizing time-stepped and their parameters that may be adjusted by the user, and discrete event simulators. The first type of simulators their attributes that may serve for data exchange with are not event-responsive. When a time-stepped simu- other simulators. No specification of units, data types lator reaches a synchronization point, it updates its or variability is given for the attributes (in contrast to coupling variables based on the latest message that is the FMI standard). Instead, users are expected to care intended for it (while any message in between synchro- for attribute compliance themselves when coupling sim- nization points except the latest one is not received). ulators. The SOM of HLA, in contrast, is much more The second type of simulator, the event-responsive sim- extensive. Similar to the meta description, it includes ulators, is interrupted in its time-progression if there is information about objects and attributes provided by a message intended for it. Using the corresponding syn- the federate. However, the SOM descriptions are much chronization mechanism, an event-responsive simulator more detailed, incorporating information about data receives all messages that come its way. With HLA, the types, units, resolution, accuracy, and so forth. simulators can choose one or the other type of operation For the interaction between mosaik and a simula- with every step forward that they take. tor, four interface functions are needed that have to be Finally, the publisher-subscriber mechanism of HLA implemented by the user. They are then called by the results in loose coupling between simulators, which al- mosaik software core to assume the basic tasks of 1) lows simple topological reconfiguration of the simulated initializing a simulator, 2) instantiating and parameter- system during runtime. izing simulation models, 3) providing input and advanc- ing the simulator in time, 4) and requesting the simu- 3 Conceptual Tool Comparison lator’s output data. In contrast, HLA provides a much wider range of functions for the coordination between In terms of their conceptual architectures, HLA and federates and the RTI which allows for more nuanced mosaik display some structural analogies. In both se- interfacing. The functions are not implemented by the tups, the simulated system is divided into subsystems user but provided by the RTI as services. The more that are represented by federates (HLA) or simulators than 20 services are grouped into clusters like federation (mosaik), respectively. The data exchange between the management, object management or time management. 4 C. Steinbrink et al.