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

How to debug OpenStudio measure

asked 2017-11-06 08:52:46 -0500

katsuya.obara's avatar

updated 2017-11-06 14:33:42 -0500

I am trying to run OpenStduio measure to create FCU with DOAS system
However, I get error as below.
Since I am new to work with OpenStudio measure, I wonder how I can approach to this problem.
Can anyone tell me appropriate approach to this issue?

Standard Output:
[08:49:19.475610 ERROR] Optional not initialized
C:/Users/katsuya.obara/BCL/f32b1b71-533a-45aa-87fc-8d4626e79ca0/4ea5fc48-c83c-41fc-9d05-61b8eee6ea9f/resources/OsLib_HVAC.rb:122:in `get'
C:/Users/katsuya.obara/BCL/f32b1b71-533a-45aa-87fc-8d4626e79ca0/4ea5fc48-c83c-41fc-9d05-61b8eee6ea9f/resources/OsLib_HVAC.rb:122:in `block in sortZones'
C:/Users/katsuya.obara/BCL/f32b1b71-533a-45aa-87fc-8d4626e79ca0/4ea5fc48-c83c-41fc-9d05-61b8eee6ea9f/resources/OsLib_HVAC.rb:121:in `each'
C:/Users/katsuya.obara/BCL/f32b1b71-533a-45aa-87fc-8d4626e79ca0/4ea5fc48-c83c-41fc-9d05-61b8eee6ea9f/resources/OsLib_HVAC.rb:121:in `sortZones'
C:/Users/katsuya.obara/BCL/f32b1b71-533a-45aa-87fc-8d4626e79ca0/4ea5fc48-c83c-41fc-9d05-61b8eee6ea9f/measure.rb:351:in `run'
:/ruby/2.2.0/gems/openstudio-workflow-1.2.1/lib/openstudio/workflow/util/measure.rb:437:in `apply_measure'
:/ruby/2.2.0/gems/openstudio-workflow-1.2.1/lib/openstudio/workflow/util/measure.rb:67:in `block in apply_measures'
:/ruby/2.2.0/gems/openstudio-workflow-1.2.1/lib/openstudio/workflow/util/measure.rb:31:in `each_index'
:/ruby/2.2.0/gems/openstudio-workflow-1.2.1/lib/openstudio/workflow/util/measure.rb:31:in `apply_measures'
:/ruby/2.2.0/gems/openstudio-workflow-1.2.1/lib/openstudio/workflow/jobs/run_os_measures.rb:50:in `perform'
:/ruby/2.2.0/gems/openstudio-workflow-1.2.1/lib/openstudio/workflow/run.rb:256:in `step'
:/ruby/2.2.0/gems/openstudio-workflow-1.2.1/lib/openstudio/workflow/run.rb:210:in `run'
:/openstudio_cli.rb:802:in `execute'
:/openstudio_cli.rb:620:in `execute'
:/openstudio_cli.rb:1515:in `'
eval:85:in `eval'
eval:85:in `require_embedded_absolute'
eval:70:in `block in require'
eval:64:in `each'
eval:64:in `require'
eval:2:in `'
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-11-06 09:52:56 -0500

Line 122 of the OsLib_HVAC.rb file is:

spaceType = space.spaceType.get

Calling the spaceType method on a Space object returns an OptionalSpaceType object. If you try to get and Optional type that doesn't point to an acutal object, you will recieve the 'Optional not initialized' error. See the Measure Writing Guide section on the boost:optional type.

Based on this I would surmise you are trying to run the measure on a model that has spaces without space types assigned.

The right way to handle this case in the measure would be to check if space.spaceType.is_initializedor if not space.spaceType.empty? and then call space.spaceType.get if true, and (perhaps) skip that space if false.

edit flag offensive delete link more


According to your comment, I tried to investigate the script and I suspect below sentence is causing problem.

zonesSorted = OsLib_HVAC.sortZones(model, runner, options, space_type_to_edits_hash)

However, since I am new to ruby and OS api, I cannot imagine what this script actually does. Referring to my experience from Python, I would print the variable for debugging in this case. Are there similar function I can use in this case?

katsuya.obara's avatar katsuya.obara  ( 2017-11-07 18:12:19 -0500 )edit

The problem is caused by space.spaceType.get trying to get an empty space type. The first line after the error message in the standard output tells you which line in what file is causing the error. In ruby, you can use puts to print variables/objects/whatever to help debug. Or all these other ways.

ericringold's avatar ericringold  ( 2017-11-07 18:50:17 -0500 )edit

Your Answer

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

Add Answer

Training Workshops


Question Tools

1 follower


Asked: 2017-11-06 08:52:46 -0500

Seen: 392 times

Last updated: Nov 06 '17