XInTheLoop is a Modelica library for interfacing a model with an external system for continuous interaction during real-time simulation of the model. The external system in this case is a software tightly coupled with e.g. a physical process hardware, some user interface, another model simulation, a computational service, or some other software service.
Note that this library might also work with other Modelica frameworks and at other platforms that win64, but that is not tested during development.
Use the DOI number above when citing all (including future) versions of this library. When clicking the DOI link, it will resolve to the DOI information of the currently latest version, and the same page also contains a section with DOI numbers to use for each released version when citing one particular version.
A generic UDP based protocol is developed to exchange values between the Modelica model and the external system in both directions at regular intervals.
Together with a set of generic support blocks, it should be easy to implement your own blocks for interfacing one particular external system.
The external system can be developed in any language/framework that support UDP communication. A set of included Python scripts for UDP communication in the example use cases can be used as inspiration.
The Site1 example is a test model and interfacing blocks for one particular external FCS system containing a fuel cell, a DC-to-DC-converter, a battery, and a variable load.
The Site2 example contains test models that use a UDP protocol to exchange values with an external system running a StasHH compatible fuel cell module (FCM), where a fuel cell control unit (FCCU) handle the StasHH Digital Interface via a CAN bus, and python scripts acting as a relay between the UDP protocol and the CAN protocol.
- Modelica v4.0.0
- Modelica_DeviceDrivers v2.1.1
Due to a bug in OMEdit v1.20 for Windows, models using this library from that OMEdit version need to add -lws2_32
to the C/C++ Compiler Flags (Optional) in the General tab of Simulation Setup to compensate for the bug as described in modelica-3rdparty/Modelica_DeviceDrivers#369.
The bug is still present in OMEdit v1.23.1 for Windows.
The initial versions of this library has been developed as part of the Virtual-FCS project. The main library VirtualFCS can be used to build advanced FCS models, and then combined with this library to include an external system in the loop.
This library has been further developed as part of the StasHH project.
- The Virtual-FCS project has received funding from the Fuel Cells and Hydrogen 2 Joint Undertaking (now Clean Hydrogen Partnership) under Grant Agreement No. 875087.
- The StasHH project has received funding from the same Joint Undertaking under Grant Agreement No. 101005934.
- This Joint Undertaking receives support from the European Union's Horizon 2020 Research and Innovation Program, Hydrogen Europe and Hydrogen Europe Research.
This library is shared under an MIT license. For more information, please see the LICENSE file.