After the application of the first prototype (the Intercom library) for co-simulating the overture and EnergyPlus models of the case study, some limitations were identified. To overcome these limitations, the final prototype must
To be able to comply with all the requisites, for the final prototype Functional Mock-up Interface (FMI) has been used to co-simulate. This standard allows using several instances of a model and coupling several tools. Also, the tools to be coupled already have FMI support developed.
Functional Mock-up Interface or FMI is a tool independent standard to support both model exchange and co-simulation of dynamic models using a combination of XML files and compiled C-code. For more information about this standard click here.
FMI is used to allow co-simulation. This standard allows using several instances of a model and coupling several tools. Overture and EnergyPlus already have FMI support.
As a part of the project INTO-CPS (click here for more information about the project) FMI support for overture has been developed. How to install the tool and export a model from overture to FMU is explained here.
This support is based on Crescendo Tool and there is an automated export function from Overture for FMI 2.0.
1.1 Generating an Overture FMU for the Example
Starting from the overture project, first the FMI library must be added to the project.
In order to use this model sensor and actuator data variables must be changed. In the original model, the data coming from sensor and the data sent to the actuator are real, but for FMU a FMI port must be used, so for each sensor and actuator a class is created. The controller will work with instances of this classes. The constructor is also changed to pass the initial values of the sensor and actuator data.
Changes made in the Controller.vdmrt:
New classes:
Changes are also necessary in System.vdmrt
To see the exact changes applied to the project click here.
In the Hardware interface some annotations have to be written to specify the inputs and outputs of the FMU.
The last step is to send to export the FMU. There are two options: to export the FMU including the source code or including the binaries.
Adding FMI library to project
Hardware interface class with annotations
Exporting FMU
To export EnergyPlus models to FMU, EnergyPlusToFMU tool is used (to install this tool click here). EnergyPlusToFMU is a software package written in Python which allows to exports models of EnergyPlus 8.0 or newer versions to FMU.
2.1 Generating an EnergyPlus FMU for the Example
New information about the FMU interface must be added to the idf file of the EnergyPlus model. These three items must be included:
To create a FMU, EnergyPlusToFMU python script has been executed with the appropriate parameters.
How to declare the variables in the idf
Python script to create FMU
For co-simulating the generated FMUs, a tool or simulation environment is needed. Building Controls Virtual Test Bed (BCVTB) has been selected in this case. BCVTB offers support for Functional Mock-up Units (FMU) for co-simulation and model-exchange for the Functional Mock-up Interface (FMI) 1.0 and 2.0. It has a graphical interface for building models connecting imported FMUs.
3.1 Generation of the Overture FMU
As BCVTB does not support the FMI 2.0 in co-simulation, FMUs for version FMI 1.0 has to be created. The tool used is FMU SDK 2.0.4 (FMUSDK), a free software development kit provided by QTronic. To download this tool click here.
To install this tool Microsoft Visual Studio 2005 (VS8), 2008 (VS9), 2010 (VS10), or 2012 (VS11) must be installed. To compile with another compiler, you must adapt the batch files.
Steps to generate the Overture FMU:
The FMU examples provided by the tool are all in the same file, but in our case, many files have to be compiled, so the build_fmu.bat file has to be changed. This line has changed from:
to:
The Shading control example in BCVTB is opened and import the generated Overture FMU and replace the shadingController by the imported FMU.
Import the generated Overture FMU
Replace shadingController