Unwanted sub-timestep callbacks in EMS (Python API) [closed]

asked 2021-08-18 10:17:03 -0500

mechyai's avatar

Hello,

I am running some test scripts with the EMS Python API and am seeing redundant callbacks for each simulation timestep. It doesn't happen entirely throughout the simulation, however, but still quite often. My understanding is there should only be one unique callback per timestep.

It is better to explain this visually. This model has 6 timesteps/hour and the calling point is somewhat arbitrarily "Callback After Predictor After HVAC Managers".

Below, is a dataframe snippet from the original simulation when I noticed my issue. You can see the first hour is normal, but the rest seem to be running my callback function more frequently than desired. And you can see the Datetime is messed up, going backward occasionally (yellow highlight). Although, the data is the same for these sub-timesteps luckily.

For a 365-day simulation, this resulted in 80,198 callbacks. Way more than (6 timesteps/hr) * (24 hr/day) * (365 day) = 52,560 callbacks/timesteps expected.

image description

To fix this, I added this bit of Python code to catch when the read timestep is the same as the previous one, then ignore that callback.

image description

This showed good results, with chronological Datetime, no redundancy, and 52,560 callbacks as seen below.

image description

However, I am not confident this is a solution. I am curious why I was experiencing this redundant callbacks / sub-timesteps in the first place, and if this means there are any bugs with my model or the API?

Thank you

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by mechyai
close date 2021-08-18 10:17:41.711417

Comments

Duplicate of this post.

Aaron Boranian's avatar Aaron Boranian  ( 2021-08-18 10:27:47 -0500 )edit