How to run EnergyPlus-FMU using PyFMI
Asked Answered
S

2

6

I am in trouble in simulating the EnergyPlus-FMU by PyFMI. I created an EnergyPlus FMU using the reference building model. I am using PyFMI2.5. How do I run the do_step() function?

from pyfmi import load_fmu

model = load_fmu("MyEnergyplus.fmu")
start_time = 0
final_time = 60.0 * 60 * 24 * 3 #seconds
step_size = 60 # seconds

opts = model.simulate_options()
idf_steps_per_hour = 60
ncp = (final_time - start_time)/(3600./idf_steps_per_hour)
opts['ncp'] = ncp

t = 0

status = model.do_step(current_t = t, step_size= step_size, new_step=True)

The error I got:

    File "test_fmi2.py", line 15, in <module> status = model.do_step(current_t = t, step_size= step_size, new_step=True) 

AttributeError: 'pyfmi.fmi.FMUModelME2' object has no attribute 'do_step'

I double checked the APIs of PyFMI, and didn't find any problem. How to enable the simulation? Thanks.

Serbocroatian answered 14/8, 2019 at 20:19 Comment(0)
E
4

From the output we can see that the FMU that you have loaded is an Model Exchange FMU that do not have a do step function (only Co-Simulation FMUs have that). For more information about the different FMU types, please see the FMI specification.

To simulate an Model Exchange FMU, please use the "simulate" method. The "simulate" method is also available for Co-Simulation FMUs and is the prefered way to perform a simulation

Eschar answered 16/8, 2019 at 6:5 Comment(2)
Thanks for your fast response!!! What i am trying to do is to exchange a parameter between two models each time step. Because my models on two sides have their own solver. I am trying to use pyfmu as a broker. '''Basically model_A -->do its own calculation --->send a parameter X to pyfmi ---> received by model_B -->use this parameter X to do calculations within B to generate Y ---> send Y through pyfmi back to model_A. The process repeat within each timestep until the end of the simulation. Please advise how do i realize this idea. Thanks.Serbocroatian
How do you generate the energyplus fmu? By simulationresearch.lbl.gov/fmu/EnergyPlus/export ? Then it should be an FMI 1.0 CS FMU. Could you please share the FMU or the contained modeldescription.xml file (or at least the beginning of it)?Cadel
X
1

Not knowing how you setup the fmu, I can at least say that you forgot model.initialize(start_time,final_time).

Xiomaraxiong answered 3/2, 2020 at 8:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.