I have two FMU developed with different simulation tools. I would like to connect them through some variables and run a co-simulation with an open source tool as OpenModelica. This co-simulation has to be rather tight as both FMU have discontinuities.Is that possible?. Could you provide a simple sample?
How to do co-simulation with two FMU models
simulation;fmi;openmodelica
Model Exchange vs. Co-SimulationThis depends on how you export your FMUs: You can either use FMI for model-exchange or FMI for co-simulation.In the model-exchange scenario, the FMU contains only the model and no solver. Therefore the solver of the importing simulator is used.In the co-simulation scenario, the FMU contains both the model and a solver. Here the importing simulator acts as the master of the co-simulation.In both cases you will need a simulator that supports the import of the respective FMU type. OpenModelica has support for import of model-exchange FMUs since version 1.8.0. Hence, if you have two FMUs that you have exported using FMI for model-exchange, you can import them both into OpenModelica and simulate them using the OpenModelica solver. Note that strictly speaking, this isn't a real co-simulation since only one solver is involved.If you want to use a separate solver for each FMU (i.e. perform a real co-simulation) then you should only export one of the models as an FMU using FMI for co-simulation. Import that FMU into the simulator of the other model. Note that OpenModelica 1.8.0 doesn't support FMI for co-simulation.Model Exchange ExampleHere's a working example (tested in Dymola, I don't have OpenModelica installed here right now):File TestFMU1.mo:model TestFMU1  parameter Real p = 1.0;  connector TestOutputConnector    output Real value;  end TestOutputConnector;  TestOutputConnector c;equation   c.value = p;end TestFMU1;File TestFMU2.mo:model TestFMU2  Real result;  connector TestInputConnector    input Real value;  end TestInputConnector;  TestInputConnector c;equation   result = c.value;end TestFMU2;Export both of these as FMUs. Then import them and combine them as follows:model TestConnection  TestFMU1_fmu OutputFMU;  TestFMU2_fmu InputFMU;equation   connect(OutputFMU.c_value, InputFMU.c_value);end TestConnection;OpenModelicaIt seems that OpenModelica currently does not support simulating two FMUs simultaneously. This is a known bug.