Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
3

Debugging of workspace.addObjects() input

asked 2018-11-14 16:51:11 -0500

mldichter's avatar

updated 2018-11-15 08:00:52 -0500

The problem I have with workspace.addObjects() is the function doesn't add any of the input objects to the idf if one or more of the objects is invalid. This makes debugging very difficult because all I know is that there is at least one problem with one of the objects in the input array.

https://openstudio-sdk-documentation....

Most recently, this was apparent when the RunPeriod object fields changed from the energyplus 8.9 to 9.0 version and many of my measures broke that would load external idf objects specifying the base building model.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2018-11-15 17:16:00 -0500

@mldichter I just documented the current behavior in an issue; the current behavior is not ideal. I do have some possible work arounds for now.

If you assign a variable to the results of addObjects and check if that is empty, that will indicate one or more objects have an issue that prevented the objects from importing. When you see this happen, you can add a puts statement of the workspace that addObjects is being called on.

 source_idf = OpenStudio::IdfFile::load(OpenStudio::Path.new(source_idf_path)).get
 puts source_idf

You can then diff that with the original IDF file.

There is also an addObjet method you could use that does bring in the object even if invalid, the issue above describes how to use this. This would then result in a simulation error at run time that might point to the problem object.

Either way, the IDF will need to be updated if there are IDD changes in EnergyPlus and you want to use it with newer version of OpenStudio/EnergyPlus. We don't currently have any measures that run the EnergyPlus version updater. The "InjectIdfObjects" measure takes a user specified file. If a measure gets IDF files from a resource folder, it could be good to add min/max version tags to the measure matching which version of EnergyPlus is supported for the objets in the IDF. You could also have multiple IDF objets for different EnergyPlus versions that will get selected based on what version of OpenStudio the measure is being run on.

edit flag offensive delete link more

Comments

@David Goldwasser Has the behavior of workspace.addObject() changed since this unmethours question?
https://unmethours.com/question/32993...
I had great difficulty specifying correct object order when using the workspace.addObject() method instead of the workspace.addObjects() method. Otherwise invalid object fields were not added to the idf file and left blank, which is why I switched to using workspace.addObjects(), which has its own difficulties.

mldichter's avatar mldichter  ( 2018-11-19 15:13:56 -0500 )edit

@mldichter, I don't think it has changed. I would keep tabs on this git issue that @macumber made earlier today.

David Goldwasser's avatar David Goldwasser  ( 2018-11-19 15:44:53 -0500 )edit

Your Answer

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

Add Answer

Careers

Question Tools

2 followers

Stats

Asked: 2018-11-14 16:51:11 -0500

Seen: 212 times

Last updated: Nov 15 '18