# Hybrid Causality

The causality of a subsystem in a distributed system plays an important role in defining the connectivity of the subsystem, and in some cases it is hard to determine the causality, and thereby the connectivity, of a submodel on beforehand before knowing the connecting environment. One classical example for illustrating the causality-connectivity dependency is the mass-damper-spring system, which is as a set of first order differential equations given with integral causality as $$\begin{split} \dot{x}_1&=x_2\\ \dot{x}_2&=\frac{1}{m}(\tau-bx_2-kx_1) \end{split} \label{intcausal}$$ where $x_1$ and $x_2$ are the position and the velocity of the system, respectively, $m$ is the mass, $b$ is the damping coefficient, $k$ is the spring stiffness and $\tau$ is an exciting force given as input to the system. Typically, this mass spring system would be connected to other subsystems in a distributed system through the exchange of power, which means that $x_2$ is given as output of the mass-damper-spring system.

However, this subsystem can also be implemented with differential causality. Hence, $$\begin{split} \dot{x}_1&=v\\ \tau &=m\frac{dv}{dt}+bv+kx_1 \end{split} \label{diffcausal}$$ As can be seen from the set of equations, now the input is given as the velocity v, and the output is the exciting force $\tau$. Both these causality options, and thereby connectivity options, may be equally relevant depending on the model environment in a distributed system.

Since it is preferred that a distributed simulation master algorithm does not have to perform iterations between subsystems because of causality conflicts, it is of great interest to either design a submodel with a specific causality and connectivity, or to implement the submodel as a hybrid causality model, meaning that the model has the possibility to be connected to subsystems with different causality options, and, in some cases also change causality online during a simulation.

A typical application of hybrid causality models would be in a weak marine power grid containing more than one energy source (such as generators, batteries and fuel cells). Hence, only one of the energy sources can set the power grid voltage (since the power grid load can not do it because of various reasons), mathematically speaking, and if starting and stopping of energy sources are to be studied, hybrid causality models of the energy sources are needed [1].

Such a hybrid causality model can be implemented in many different ways, such as two parallel models with switching in between, implemented as one submodel in the distributed system, dependent on logical choices and active- and passive inputs and outputs, where the differential causality model is solved by a more advanced numerical solver. Another approach is proposed in [2] where a low-pass filter with integrator effect is used to regain the state that is lost when going from integral causality to differential causality. This method keeps the number of states in the system constant and remove any needs for iterations [3].

The following example illustrates the concept of hybrid causality models.

Example 1 Hybrid Causality

A single, linear differential equation is given in integral causality as $$\begin{split} \dot{x}&=ax+bu\\ y&=hx \end{split}$$ where $x$ is the state, $u$ is the model input, $y$ is the model output and $a$, $b$ and $h$ are model parameters. The corresponding differential causality is given as $$\begin{split} x&=\frac{y}{h}\\ u&=\frac{1}{b}(\dot{x}-ax) \end{split} \label{diffcausalex}$$ Now, $y$ is the model input and $u$ is the model output. Also, $x$ is no longer an explicit state in the system. By applying the transfer function $$h(s)=\frac{s}{Ts+1},$$ where $T$ is a time constant to be determined, to the differential causality, the state is regained and the system can be expressed as $$\begin{split} \dot{\xi}&=-\frac{1}{T}\xi+\frac{1}{Th}y\\ u&=-\frac{1}{Tb}\xi+\frac{1}{bh}(\frac{1}{T}-a)y \end{split}$$ where $\xi$ is the new state. It can also be verified that if switching of causality is considered online during a simulation, the initial condition for $\xi$ when going from integral causality to reformulated differential causality at time $t_0$ is given as $$\xi(t_0)=(1-aT)x(t_0)-Tbu(t_0)$$ and, the initial condition for $x$ when switching from the reformulated causality to the integral causality at time $t_0$ is given as $$x(t_0)=\frac{y(t_0)}{h}$$ Note that the filter time constant $T$ must be chose based on local solver stability as well as global distributed simulation stability. The advantages by keeping the size of the state-space model constant is that if $T$ is chosen correctly, the same solver can be used for the integral causality model and the reformulated differential causality model and the only changes are that the system dynamics and the initial conditions change, and one can use the same input and output ports defined for the model for both causality options. The disadvantage is of course that the filter adds an additional phase to the dynamics, but this phase can be minimized if $T$ is chosen correctly for the subsystem. This has been analysed thoroughly in [3].

1. S. Skjong and E. Pedersen., 2017. A Real-Time Simulator Framework for Marine Power Plants with Weak Power Grids.. Elsevier - Mechantroincs.
2. S. Skjong and E. Pedersen, 2016. The Theory of Bond Graphs in Distributed Systems and Simulations. International Conference on Bond Graph Modeling and Simulation (ICBGM'16), Montreal, Canada. Spciety for Modeling & Simulation International.
3. S. Skjong and E. Pedersen, 2017. Hybrid Causality Model Framework including Explicit Reformulation of Differential Algebraic Equations using Perturbations corresponding to added System Dynamics. Work in progress.
• vpf/hybrid_causality.txt