6.2. Description

In the BCVTB, data is exchanged between the different clients using a fixed synchronization time step. There is no iteration between the clients. In the co-simulation literature, this coupling scheme is referred to as quasi-dynamic coupling, loose coupling or ping-pong coupling. See [Hensen (1999)] and [Zhai and Chen (2005)] for details. The algorithm for exchanging data between clients is as follows: Suppose we have a system with two clients, where each client solves an initial value ordinary differential equation that is coupled to the ordinary differential equation of the other client. Let N N denote the number of time steps and let k { 0 , , N } denote the time steps. For some n 1 , n 2 , let f 1 : n 1 × n 2 n 1 and f 2 : n 2 × n 1 n 2 denote the functions that compute the next value of the state variables in simulator 1 and 2. Note that these functions are defined by the sequence of code instructions executed in the respective simulator. The simulator 1 computes, for k { 0 , , N - 1 } , the sequence

x 1 ( k + 1 ) = f 1 ( x 1 ( k ) , x 2 ( k ) ), ,

and, similarly, the simulator 2 computes the sequence

x 2 ( k + 1 ) = f 2 ( x 2 ( k ) , x 1 ( k ) ),

with initial conditions x 1 ( 0 ) = x 1 , 0 and x 2 ( 0 ) = x 2 , 0 . An implementation difficulty is presented by the situation that f 1 ( , ) and f 2 ( , ) need to know the initial value of the other simulator. Thus, at k=0 , both simulators exchange their initial value x 1,0 and x 2,0 . To advance from time k to k+1, each simulator uses its own time integration algorithm. At the end of the time step, the simulator 1 sends the new state x 1 (k+1) to the BCVTB and it receives the state x 2 (k+1) from the BCVTB. The same procedure is done by the simulator 2. The BCVTB synchronizes the data in such a way that it does not matter which of the two simulators is called first.

In terms of numerical methods for ordinary differential equations, this scheme is identical to an explicit Euler integration, which is an integration algorithm for a differential equation

x ˙ = h ( x ) , x ( 0 ) = x 0 ,

where h : n n for some n . On the time interval t [ 0 , 1 ] , the explicit Euler integration algorithm leads to the following sequence:

Step 0: Initialize counter k = 0 and number of steps n .
Set initial state x(k)=x 0 and set time step Δt = 1/N.
Step 1: Compute new state x(k+1) = x(k) + h(x(k)) Δt .
Replace k by k+1.
Step 2: If k=N stop, else go to Step 1.

In the situation where the differential equation is integrated over time using co-simulation, the above algorithm becomes:

Step 0: Initialize counter k = 0 and number of steps n
Set initial states x 1 (k)= x 1,0 and x 2 (k)= x 2,0 .
Set time step Δt = 1/N.
Step 1: Compute new states
x 1 ( k + 1 ) = x 1 ( k ) + f 1 ( x 1 ( k ) , x 2 ( k ) ) Δ t , and
x 2 ( k + 1 ) = x 2 ( k ) + f 2 ( x 2 ( k ) , x 1 ( k ) ) Δ t .
Replace k by k+1.
Step 2: If k=N stop, else go to Step 1.

This algorithm is implemented in the BCVTB. It does not require an iteration between the two simulators.

We note that other data synchronizations may be possible. For example, in strong coupling, within each time step, simulators exchange data until a convergence criteria is satisfied. This implementation requires the numerical solution of a nonlinear system of equations in which the termination criteria is a function of the state variables of the coupled simulators. However, many building simulation programs contain solvers that compute with relatively coarse precision. This can introduce significant numerical noise which may cause convergence problems for the co-simulation. The computing time of strong coupling vs. loose coupling of EnergyPlus and TRNSYS was compared by [Trcka et al. (2007)]. Although loose coupling required shorter synchronization time steps, the work per time step was smaller (as no iterations were needed) which caused loose coupling to compute faster than strong coupling. An additional implementation benefit of loose coupling is that state variables need not be reset to previous values. Thus, loose coupling is easier to implement, is numerically more robust and it computed faster in the experiments reported by [Trcka et al. (2007)].