As mentioned in the introduction, FMIGo! is a set of tools for dealing with the FMI standard. The main components are:
fmigo‑mpi fmigo‑master fmigo‑server | Execution backend |
ssp‑launcher.py | Python script for parsing and launching SSPs |
pygo | Python library for abstracting and connecting FMUs, and for dealing with output data from the execution backend |
wrapper | A set of CMake and Python scripts plus C code for converting ModelExchange FMUs to Co-Simulation FMUs |
cgsl | Small library simplifying how we deal with the GNU Scientific Library (GSL) |
Fortunately, distributed access can solve these issues. In describing how and presenting a benchmark, this paper builds on the work presented in 10, which introduced a framework for accessing.
The execution backend consists of two sets of binaries: fmigo‑mpi and fmigo‑master/fmigo‑server. fmigo‑mpi is used when communication over MPI is desired, fmigo‑master and fmigo‑server are used when TCP/IP (ZeroMQ) communication is desired.
The backend has the following properties:
First off, a word of advice: if you only have a single FMU, you are probably better off using simpler tools such as PyFMI. The primary purpose of FMIGo! is to make it possible to connect two or more FMUs and have such combinations run with reasonable performance without numerically blowing up. With that said we can go on with the rest of this section:
In order for FMIGo! to be of much use, you must pick some method of coupling your simulations. For physical systems FMIGo! provides the SPOOK solver by Claude Lacoursière. Another option is to use the NEPCE method developed by Edo Drenth, which involves adding sinc² filters to FMU outputs and adding stiff springs+dampers to relevant inputs. Some of that work can be automated using our ME→CS FMU wrapper tool. Using special purpose solvers may also be necessary, such as exponential integrators. FMIGo! does not provide this, unless GSL does. On to the example:
You have two FMUs, fmu0.fmu and fmu1.fmu, that you wish to connect with a shaft constraint. By default, shaft constraints are holonomic, meaning the solver will try to keep both angles and angular velocities together. The solver (master) expects to be given references to angle outputs, angular velocity outputs, angular acceleration outputs, and torque inputs. It also expects to be able to request the the partial derivative of angular acceleration wrt torque (mobility aka inverse mass or inverse moment of inertia). Finally, the FMUs must have save/restore functionality (fmi2GetFMUState and friends).
If fmu0.fmu has variables outputs theta1, omega1, alpha1 and tau1, and fmu1.fmu has angle2, angularVelocity2, angularAcceleration2, torque2, then the invocation is:
The -n option to mpiexec must be the number of FMUs plus one.
Other kinematic constraints are also possible, such as lock constraints, ball constraints and multiway constraints. See the manual for more information about these, and other invocation details.
The output of the backend can be CSV (comma separated values, default), SSV (space separated values) or Matlab .mat files. Column names are 'fmu%i_%s' where %i is the FMU ID (zero-based) and %s is the name of the relevant output variable. Only the variables listed in <Outputs> in modelDescription.xml will end up in the output data. In the above example, some output column names might be fmu0_theta1 and fmu1_angle2.
ssp‑launcher.py is used for launching SSPs. It supports enough of the SSP standard for our purposes, plus our extensions listed in tools/ssp/FmiGo.xsd.
Ensure that the fmigo‑* executables are in your $PATH, and invoke ssp‑launcher.py on your SSP:
Output format is CSV by default.
pygo consits of some Python classes for abstracting and connecting FMUs (a bit like SSP), and code for converting the output of the backend to HDF5 format. Claude knows more.
The wrapper converts ModelExchange FMUs to Co-Simulation FMUs by adding an ODE solver, partial derivatives and optional sinc² filters suitable for NEPCE coupling.
Example invocation, converting ME.fmu into CS.fmu in Release mode:
Invoke python wrapper.py --help for full help. The resulting FMUs are subject to the GNU General Public License version 3 (GPLv3).
cgsl is used as a convenience library for us, but may be of use for other people. Check out tools/csgl/demo in the source code for an example.