Question-and-Answer Resource for the Building Energy Modeling Community
Get s tarted with the Help page
Ask Your Question
2

Do Step error when using PYFMI

asked 2021-07-09 07:47:06 -0500

jdominguez94 gravatar image

updated 2021-07-09 16:27:28 -0500

Hello guys,

I am trying to perform a simple Do_Step simulation using an .IDF included in the pack of the EnergyPlusToFMU framework.

However, when I try to carry out the simulation step by step, this error appears

FMIL: module = Model, log level = 2: [error][FMU status:Error] fmi2DoStep: An error occured in a previous call. First communication time: 0.000000 !=tStart: 1.000000.

FMIL: module = Model, log level = 2: [error][FMU status:Error] fmi2DoStep: An error occured in a previous call. First communication time: 900.000000 !=tStart: 1.000000.

FMIL: module = Model, log level = 2: [error][FMU status:Error] fmi2DoStep: An error occured in a previous call. First communication time: 1800.000000 !=tStart: 1.000000.

FMIL: module = Model, log level = 2: [error][FMU status:Error] fmi2DoStep: An error occured in a previous call. First communication time: 2700.000000 !=tStart: 1.000000.

This is the code I am using. I do not know what else I can do since the model was initialized

from pyfmi.fmi import FMUModelCS2
ErrorDict=['FMI_OK', 'FMI_WARNING', 'FMI_DISCARD', 'FMI_ERROR','FMI_FATAL','FMI_PENDING']

house = FMUModelCS2("/workspaces/Eplus93/source/house/example.fmu")
starttime=0
finaltime=86400
house.initialize(starttime, finaltime,True)

stepsize=900 # Each 15 minutes
opts = house.simulate_options()
idf_steps_per_hour = 4
ncp = (finaltime-starttime)/(3600./idf_steps_per_hour)
opts['ncp'] = ncp
t_step=starttime
var=[]

while t_step < 1*3600:
    status = house.do_step(current_t=t_step, step_size=stepsize, new_step=True)
    status=ErrorDict[status]
    var.append(['Status flag'+':'+str(status),t_step,np.float(house.get('TRooMea'))])
    t_step +=stepsize

According to Dr. Wetter in link text it seems that EnergyPlus' ExternalInterface object imposes a one-time step delay. Nevertheless, I do not have a clue about how to make the code get this.

The FMU used is here: link text

Thank you very much!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2021-07-09 07:48:29 -0500

jdominguez94 gravatar image

updated 2021-07-09 16:05:20 -0500

The problem was solved :D !!! The problem was related to the fact that prior initializing the model, the experiment must be set up through:

house.setup_experiment(stop_time=final_time) #This was the missing part!!
house.initialize(start_time, final_time,True)

I used the same code with an OpenModelica generated FMU, and there is no problem over there. So, it seems to be a tricky issue of E+.

edit flag offensive delete link more

Comments

So far I know, in latest versions of PyFMI, model.initialize() calls the model.setup_experiment()(see https://github.com/modelon-community/... - line 4770). This is the reason why parameters such as start_time and stop_time are passed on to the method. I am currently using version 2.8.5 which is a little bit old and doesn't have to call model.setup_experiment() explicitly. You may need to check your version and see if an update is needed.

Thierry Nouidui gravatar image Thierry Nouidui  ( 2021-07-10 00:29:27 -0500 )edit

Thank you very much for your rapid responses! I checked the version and is the 2.8.10, seems to be the latest one. Eventually, it is very strange since as you pointed out, model.initialize() invokes the model.setup_experiment() function.

jdominguez94 gravatar image jdominguez94  ( 2021-07-12 12:59:15 -0500 )edit
1

answered 2021-07-09 08:03:20 -0500

I am not familiar with FMUModelCS2 and hence suggest to use the load_fmu() function to load/instantiate your FMU instead.

so the code will look a bit like this

 from pyfmi import load_fmu
 house=load_fmu("/workspaces/Eplus93/source/house/example.fmu")

then later you will initialize your FMU with

house.initialize(start_time=starttime, stop_time=finaltime)
edit flag offensive delete link more

Comments

Thank you for your rapid response! As suggested by you, I did the changes but the problem still remains

jdominguez94 gravatar image jdominguez94  ( 2021-07-09 13:08:58 -0500 )edit

Which version of E+ to FMU did you use to export the IDF?

Thierry Nouidui gravatar image Thierry Nouidui  ( 2021-07-09 13:27:31 -0500 )edit

I generate the IDF by using OpenStudio, and the E+2FMU version I am using to build the FMU is the 3.1.0

jdominguez94 gravatar image jdominguez94  ( 2021-07-09 14:16:09 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

 

Question Tools

1 follower

Stats

Asked: 2021-07-09 07:47:06 -0500

Seen: 86 times

Last updated: Jul 09