# Co-simulation

In co-simulation, the different subsystems that form a coupled problem are modeled and simulated in a distributed manner. Hence, the modeling is done on the subsystem level without having the coupled problem in mind. Furthermore, the coupled simulation is carried out by running the subsystems in a black-box manner. During the simulation, the subsystems will exchange data. Co-simulation can be considered as the joint simulation of the already well-established tools and semantics; when they are simulated with their suitable solvers. Co-simulation proves its advantage in validation of multi-domain and cyber-physical systems by offering a flexible solution that allows consideration of multiple domains with different time steps, at the same time. As the calculation load is shared among simulators, co-simulation also enables the possibility of large-scale system assessment.

## Abstraction layers of co-simulation framework

The following introduction and structuration is proposed in.
Establishing a co-simulation framework can be a challenging and complex task, because it requires a strong interoperability among the participating elements, especially in case of multiple-formalism co-simulation. Harmonization, adaptation, and eventually changes of actual employed standards and protocols in individual models needs to be done to be able to integrate into the holistic framework. The generic layered structuration of co-simulation framework highlights the intersection of domains and the issues that need to be solved in the process of designing a co-simulation framework. In general, a co-simulation framework consists of five abstraction layers:
Structuration of co-simulation framework :
| Abstraction layer | Description | Associated issues |
| Conceptual | Highest level where the models are considered as black boxes and the level concerns the co-simulation framework representation. | Generic structure of the framework; Meta-Modeling of the components. |
| Semantic | The level concerns the signification and the role of the co-simulation framework with respect to the open questions of the investigated system and studied phenomenon. | Signification of individual models; Interaction graph among the models; Signification of each interaction. |
| Syntactic | The level concerns the formalization of the co-simulation framework. | Formalization of individual models in the respective domains; Specification and handling the difference between a formalism to another one. |
| Dynamic | The level concerns the execution of the co-simulation framework, the synchronization techniques and harmonization of different models of computation. | Order of execution and causality of models; Harmonization of different models of computation; Resolution for potential conflict in simultaneity of actions. |
| Technical | The level concerns the implementation details and evaluation of simulation. | Distributed or centralized implementation; Robustness of the simulation; Reliability and efficiency of the simulation. |
From conceptual structuration, the architecture on which the co-simulation framework is developed and the formal semantic relations/syntactic formulation are defined. The detailed technical implementation and synchronization techniques are covered in dynamic and technical layers.

## Problem Partitioning - Architecture of co-simulation

The partitioning procedure identifies the process of spatial separation of the coupled problem into multiple partitioned subsystems. Information is exchanged through either ad-hoc interfaces or via intermediate buffer governed by a master algorithm. Master algorithm (where exists) is responsible for instantiating the simulators and for orchestrating the information exchange (simulator-simulator or simulator-orchestrator).

## Coupling methods

Co-simulation coupling methods can be classified into operational integration and formal integration, depending on abstraction layers. In general, operational integration is used in co-simulation for a specific problem and aims for interoperability at dynamic and technical layers (i.e. signal exchange). On the other hand, formal integration allows interoperability in semantic and syntactic level via either model coupling or simulator coupling. Formal integration often involves a master federate to orchestrate the semantic and syntactic of the interaction among simulators.
From a dynamic and technical point of view, it is necessary to consider the synchronization techniques and communication patterns in the process of implementation.

### Communication Patterns

There exist three principal communication patterns for master algorithms. The Gauss-Seidel, the Jacobi variants and transmission line modelling, TLM. The names of the first two methods are derived from the structural similarities to the numerical methods by the same name.
The reason is that the Jacobi method is easy to convert into an equivalent parallel algorithm while there are difficulties to do so for the Gauss-Seidel method.

#### Transmission line modelling, TLM

In transmission line modelling (a.k.a. bi-directional delay line modelling), a capacitance (or inductance) is substituted with a transmission line element with wave propagation. The time delay is set to be one time step. In this way a physically motivated time delay is introduced which means that the system can be partitioned at this location. Numerical stability is ensured since there is no numerical error, instead there is a modelling error introduced, which is more benign. This is usually the most simple to implement since it results in an explicit scheme.