FMU file simulation failed with FMPy
Dear all,
I am trying to export an .fmu fIle out of an .idf file and simulate it (using FMPy python lib) for quiet some time, but I guess I probably did something wrong, hope you can make me aware of the right way to do it.
My first goal is to have the possibility to set the AirCondition Setpoints from Python, simulate it in E+ and have the IndoorMeanAirTemperature and the AC Energy Usage plotted (or similar).
What I did so far:
- Made a model in SketchUp & OpenStudio (simulation + outputs worked)
- took the in.idf file and edited it in IDF Editor. Added External Interface Import, Export, following this Tutorial: https://bigladdersoftware.com/epx/doc...
- Converted the .idf with EnergyPlusToFMU.py to an .fmu (worked, or at least completed without errors)
The fmu generation worked lately, but i am not sure if it's correct, that in the ModelDescribtion.xml the Output is "unknown".
Currently I am facing the error, when trying to simulate:
from fmpy import *
filename = "..path/to/fmu.fmu"
result = simulate_fmu(filename)
[ERROR] fmi2Instantiate: Failed to parse the model description
and the ModelDescribtion.xml part:
<ModelVariables>
<!-- Note valueReferences are (1, 2, 3...) for causality="input" (to E+). -->
<!-- Note valueReferences are (100001, 100002, 100003...) for "output" (from E+). -->
<!-- Note the order of valueReferences should match the order of elements in file 'variables.cfg'. -->
<!-- Index for next variable is '1'. -->
<ScalarVariable name="Q" valueReference="1"
variability="continuous" causality="input"
description="IDF line 10719">
<Real start="0"/>
</ScalarVariable>
<!-- Index for next variable is '2'. -->
<ScalarVariable name="TRooMea" valueReference="100001"
variability="continuous" causality="output"
description="IDF line 10711">
<Real/>
</ScalarVariable>
</ModelVariables>
<!-- ModelStructure details for co-simulation. -->
<ModelStructure>
<!-- Outputs variables of the FMU. -->
<Outputs>
<Unknown index="2"/>
</Outputs>
</ModelStructure>
idf file snippet about external interface:
!- =========== ALL OBJECTS IN CLASS: EXTERNALINTERFACE ===========
ExternalInterface,
FunctionalMockupUnitExport; !- Name of External Interface
! --------- ExternalInterface,
! --------- FunctionalMockupUnitImport; !- Name of External Interface
!- =========== ALL OBJECTS IN CLASS: EXTERNALINTERFACE:FUNCTIONALMOCKUPUNITIMPORT ===========
ExternalInterface:FunctionalMockupUnitImport,
MeanAir.fmu, !- FMU File Name
0, !- FMU Timeout {ms}
0; !- FMU LoggingOn
!- =========== ALL OBJECTS IN CLASS: EXTERNALINTERFACE:FUNCTIONALMOCKUPUNITIMPORT:FROM:VARIABLE ===========
ExternalInterface:FunctionalMockupUnitImport:From:Variable,
THERMAL ZONE 1, !- Output:Variable Index Key Name
Zone Mean Air Temperature , !- Output:Variable Name
MeanAir.fmu, !- FMU File Name
Model_AC40, !- FMU Instance Name
TMeanAir; !- FMU Variable Name
!- =========== ALL OBJECTS IN CLASS: EXTERNALINTERFACE:FUNCTIONALMOCKUPUNITIMPORT:TO:SCHEDULE ===========
ExternalInterface:FunctionalMockupUnitImport:To:Schedule,
FMU_OthEquSen_Zone1, !- Name
Thermal Zone 1 Thermostat Schedule Type Limits, !- Schedule Type Limits Names
MeanAir.fmu, !- FMU File Name
Model_AC40, !- FMU Instance Name
QSensible, !- FMU Variable Name
0; !- Initial Value
!- =========== ALL OBJECTS IN CLASS: EXTERNALINTERFACE:FUNCTIONALMOCKUPUNITEXPORT:FROM:VARIABLE ===========
ExternalInterface:FunctionalMockupUnitExport:From:Variable,
THERMAL ZONE 1, !- Output:Variable Index Key Name
Zone Mean Air Temperature, !- Output:Variable Name
TRooMea; !- FMU Variable Name
!- =========== ALL OBJECTS IN CLASS: EXTERNALINTERFACE:FUNCTIONALMOCKUPUNITEXPORT:TO:SCHEDULE ===========
ExternalInterface:FunctionalMockupUnitExport:To:Schedule,
FMU_OthEquSen_Zone1, !- Schedule Name
Thermal Zone 1 Thermostat Schedule Type Limits, !- Schedule Type Limits Names
Q, !- FMU Variable Name
0; !- Initial Value ...