mindcoder
mindcoder

Reputation: 387

How to run EnergyPlus-FMU using PyFMI

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.

Upvotes: 6

Views: 984

Answers (2)

Scrox
Scrox

Reputation: 169

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

Upvotes: 1

Christian Winther
Christian Winther

Reputation: 1123

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

Upvotes: 4

Related Questions