Co-simulation between two models requires the use (and often the development!) of middleware to homogenize the data structures (especially for the exchanged variables). The use of a common data standard allows to avoid this problem, so here is a tutorial on EnergyPlus/Python coupling to FMI format realized by EnergyPlusToFMU (Windows installation).
Prerequisite (to install in that order!):
EnergyPlusToFMU requires a specific configuration after installation. In order to activate the Python environment within JModelica, the following command need to be run in the Windows command line terminal (cmd):
It is recommended to create a permanent alias for the Python environment of JModelica. Once the environment is activated, it becomes possible to convert a .idf file to a .FMU one, with the following instruction (Windows command line terminal):
> <path-to-JModelica-install>\Python64.bat <path-to-scripts-subdir>EnergyPlusToFMU.py \ -i <path-to-idd-file> -w <path-to-weather-file> -a <fmi-version> <path-to-idf-file>
It is important to clearly define the exchanged variables from the .idf file before it conversion to a .FMU file, according the the procedure explained in theExternal Interface Application. The .FMU is now ready to interact with the other models (Python script, JModelica model, other .FMUs...).
We can then use an IDE allowing to easily change Python interpreterPyCharm is warmly recommended) and use PyFMI, included in JModelica's Python version, to run a cosimulation: