CIM-2-mod: A CIM to modelica mapping and model-2-model transformation engine

New requirement on power systems analysis tools consider information exchange for both steady-state and system dynamics information. New European regulations on information exchange power system dynamic simulations now require coordinating TSOs operations under different scenarios, some of which require to assess the dynamic behavior of power systems under a vast array of contingencies. As a mean to comply with these regulations and to advance the state-of-the-art, this work describes the software architecture of a Model-To-Model (M2M) transformation tool to create power system dynamic models using Modelica components by linking it to data from the Common Information Model (CIM). This softwarearchitectureisconceivedtocombinetheCIMstandardlanguagewiththeModelicastandardized language, and to provide a Free/ Libre Open Source Software (FLOSS) CIM-compliant unambiguous power system modeling solution considering both steady-state and dynamic model representations of the electrical grid. © 2019PublishedbyElsevierB.V.ThisisanopenaccessarticleundertheCCBY-NC-NDlicense (http://creativecommons.org/licenses/by-nc-nd/4.0/).


Introduction
The European Network of Transmission System Operators for Electricity (ENTSO-E) adopted the regulation (EC) 714/2009 [1], which considers the need of coordination between Transmission System Operators (TSOs) with the ''use of a common transmission model dealing efficiently with interdependent physical loopflows and having regard to discrepancies between physical and commercial flows''. This common model should be used for ''common network operation tools to ensure coordination of network operation in normal and emergency conditions''. The Common Information Model (CIM) is the result of the International Electro-Technical Committee 57 (TC57) Working Group 13 and the Electrical Power Research Institute (EPRI) to provide a standard modeling semantic representation to comply with these regulations. Among the different packages that conform the CIM [2], all the basic electrical information from components and topology of the power network, with its steady-state behavior, is defined within the IEC 61970-301 CIM Core for Steady-State Information and IEC 61970-(452,453,456) CIM Core Specification Profiles. New developments on the CIM have resulted on the approval and implementation of the IEC 61970-302 CIM for Dynamics Specification and the IEC 61970-457 for Dynamics Profile. Although those packages provide a solid basis for information exchange, they do not provide needs to guarantee a consistent representation of the physical dynamic behavior that the components would expose in simulations carried out using different software tools.

Motivation
The CIM and the CGMES standards provide parameters and pictorial diagrams of power system steady-state for information exchange. Current proprietary analysis tools use these values within their internal data structures and internal solvers. These proprietary tools also support information exchange for CIM and CGMES including power systems dynamics information, that comply with the IEC 61970-302 and IEC 61970-457. However, the physical dynamic behavior is only represented in a pictorial block diagram description rather than in an explicit mathematical form (i.e. differential and algebraic equations). Thus, in this current state, interoperability can only be unassailable through the comparison of several implementation results, which depend on each individual representation embedded within the individual simulation tools' numerical routines.
With the increased need for coordination between TSOs and to comply with the aforementioned regulations, new analysis tools require unambiguous model representation. Such representation requires a computer-readable, equation-based, and standardized modeling language to describe the dynamics of each component and the power system as a whole.

Background
The Modelica language [3] is an open, standardized, objectoriented and equation-based language suitable for modeling complex cyber-physical systems. Modelica components from the OpenIPSL library help to describe the mathematical behavior of the power systems components, and they have been validated against common power system software tools as reference PSSE and PSAT [4]. To initialize a Modelica model, start values (i.e. initial guess) for all algebraic, continuous and discrete variables need to be provided [5,6]. This process is part of the numerical routines that a software developer needs to implement, and requires to set proper initial guess values to the components, which can solve the initialization problem before time-domain simulation can be performed.
The models in OpenIPSL defines start values as parameters, they correspond to the ''steady-state'' variables of algebraic variables in the transmission lines, namely voltage and powers. These values are derived from a power flow solution and other static equipment variables to be provided by the model developer when assembling a network model. These values are required by the available solvers in any Modelica compiler to calculate the initial conditions (i.e. solve the initialization problem), before conducting timedomain simulations. Note that the solution of the initialization problem is specific to each Modelica tool, the use of the Pantelides algorithm being the most common among them [7].
In the literature, there exists a Python library for reading CIM information. The PyCIM project [8] implements the CIM classes and attributes from version 14 and version 15. However, this library is not updated to support the CIM version 16, which includes information for dynamics. Other works such as [9] offer transformation capabilities, from specific modeling tools to CIM. In [10] their work is focused in graph-based algorithms to handle power systems data and topology processing within the CIM representation.
The CIM-2-MODelica tool is a prototype implementation for a model-to-model transformation involving different modeling languages. The concept of Model-to-Model (M2M) transformation [11], based on mapping rules, which associate the naming conventions from the source language with the naming convention of the target language, is implemented with basic eXtensible Modeling Language (XML) schema [12]. In the literature, there are other rule-based programming languages such as ATL [13], which is platform based. However, the XML schema and formats are more comprehensible by power system domain users and platform independent. XML is also used as the syntax format implementation for CIM models. Different Modelica compilers, such as OpenModelica, offer functionality to export Modelica code to XML.

Contributions
This M2M transformation tool proposes a modular software engine that allows to transform parametric and structural information of a power grid contained within the CIM and transform it into a Modelica model that fully describes the CIM information and it compliments it with behavior in the form of equations. This produces a computable model, i.e. one that can be simulated and analyzed using Modelica tools.
This software architecture proposes the design of a set of classes and methods for processing the information available in different CIM Profiles. A repository for mapping rules based on CIM v16 and the OpenIPSL Modelica library for power systems [14,15] is proposed. The design of this mapping repository and software architecture is based on Object-Oriented Programming (OOP) principles. Thus, the design and the current implementation could be reutilized to other programming languages. The internal package distribution of the architecture will be described, as well as the main actions or tasks to be implemented. It will follow the description of the internal class structure of the tool, which considers the main software objects that should be implemented, using other OOP programming languages, to reproduce the functionality described in this paper.
The proposed solution provides means to aid a Modelica tool in solving the initialization problem. This is done by proper use of the Modelica language features in each of the variables that should be initialized, within each of the ''initial equation'' section of every Modelica component within a whole power system. Other variables can be specified with the Modelica keyword ''start'', which is utilized to control the initialization of the required component's variables.  The CIM information source provides realistic equipment parameters and power flow solution values, required by those components. This information establishes the initial guess of the variables in power system components, which are fundamental for the solvers to calculate the proper behavior of the dynamic models utilized for the time-domain simulations. The M2M transformation process automatically provides the corresponding equipment values, power flow solution and dynamic values, available within the source CIM information profiles, to the corresponding Modelica components.

Software description
This software framework acts as a M2M transformation tool that enables the user to create a dynamic Modelica network model, with the suitable initial conditions for time-domain simulations, from the corresponding CIM model. The framework is built upon mapping rules, which connect CIM semantics with the corresponding semantic description of the OpenIPSL library components. The transformation tool works with information models built upon the IEC 61970-301 and IEC 61970-302 packages, which support the CIM v16. In its current version, it supports a limited number of components to represent the basic topology of an electrical network and different combinations of machine and controls for power plants.

Software architecture
The software framework is organized in different folders and packages to facilitate the organization of internal resources and class structure (see Fig. 1). The internal class structure is conceived to facilitate the scalability of the transformation tool, allowing the creation of additional packages for new source and target models: 1. The dist folder to store the generated library .jar files. 2. The lib folder to store the .jar files that are used within the library implementation. 3. The res folder, which contains different resources used by the library. The res.map.openipsl folder contains the implementation of the mapping rules between the CIM and the OpenIPSL. And the res.network folder contains any CIM class and attribute used as inputs for the transformation process. 4. The src folder, which contains the packages and classes to implement the transformation process. 5. The model folder, which is used by the library to store the target Modelica components, resulting from the transformation process.
Within the src folder, the software architecture is organized as follows: 1. The cim2modelica.cim package contains the JAVA classes implementing an API to handle the CIM/RDF [16] implementation from different CIM Profiles. 2. The cim2modelica.cim.map package contains the JAVA classes used to implement the class structure of the mapping rules. The transformation tool populates into this class structure the values from the source CIM model, according to the mapping rules (see Fig. 3

Software functionalities
The main algorithm follows a similar procedure as described in [17]: from a cim:Terminal class, other classes and relations are identified, but with differences in the input data and its processing.    collect the methods to create the resulting network representation with the connections between its components. The methods from the action Updated Plant Model are conceived to make the distinction from regulating equipment and machines from the rest of the components. 6. The Connect Components action creates the Modelica connect equations to form the final network topology. 7. Outside the main loop, the actions Mapping Meta-Model and SysML Meta-Model define the class structures' implementation of CIM-OpenIPSL mapping rules and OpenIPSL class components that are required to enhance the transformation tool [18,19].

Software implementation
The transformation tool is implemented with different class structures that implement the methods of the functionalities described in Fig. 2. 1 1. The Mapping Meta-Model functionality is designed to create the XML mapping rules and JAVA class structure. This class structure is obtained applying the JAXB technology, which provides and API to convert XML schemas into JAVA classes, and vice versa [20]. An example of the resulting class structure is shown in Fig. 3. From the XML mapping rules, classes such as GENROUMap are automatically generated with the  Fig. 4 shows this class structure, used to create a network representation with the connector and components instances and their attributes.
On top of the class hierarchy, Fig. 5

Illustrative example
To illustrate the usage and results of the application of the transformation tool, the Klein-Rogers-Kundur Two-Area power network [21] is used. The transformation tool receives as inputs the source CIM information divided into different CIM profiles that contains the information from the network model and generates as output an equivalent target Modelica components. The outputs result in a file system with the main model file, which contains the auto-generated Modelica model, and additional files that contain the Modelica implementation of power plant representations. The case in Fig. 6 shows an auto generated Two-Area Modelica network, 2 simulated in OpenModelica with a Runge-Kutta solver, with a fix time-step of 0.02. This scenario represents the behavior of the network with the presence of a fault event at the Bus connected to generator 2, with an impedance of 0.11j , at t = 5 during 0.1 s.

Conclusions
This work shows the software architecture organization and main implementation of the M2M transformation, tool, based on the CIM and Modelica languages for the information exchange and simulation of CIM-compliant power system dynamic models. The proposed implementation follows a modular and scalable design and implementation for mapping rules and network generation that can be extended to support other modeling languages. The proposed implementation considers JAVA as the main programming language, and use of libraries to process XML and CIM/RDF files. Moreover, the implementation is open to any Object-Oriented Programming language, with support to the mentioned semantics.
The design of the mapping was first proposed in [18], and then was further explained with a proof of concept of methodology for a model-to-model transformation workflow described in [19]. With this implementation, instances of OpenIPSL components, with proper power flow solutions and equipment values from a CIM model, can be automatically generated and connected to form a Modelica network model, suitable for dynamic simulation studies. The instantiation process complies with the proof of concept presented in the Annex F of the new CGMES 2.5 standard guide lines [22]. It corresponds to the IEC 61970-600 definition, which proposes the use of Modelica to exchange user-defined models.
In future work, the internal package distribution of the software architecture will be described in detail, as well as the main features that were crucial in the implementation herein. Such information would allow to extend the tool or to re-implement it to take advantage of other programming or modeling languages.
The M2M is in constant maintenance of the Github repository that hosts the code. Better implementations of the main algorithm for a general identification of CIM classes is under investigation and development.
2 Further details on the use of the transformation tool are given within the user's guide which can be found in the tool repository's docs folder.