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.

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

2 Comments

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.
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)?
1

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.