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

OpenStudio measure interactive debugging

asked 8 years ago

antonszilasi's avatar

updated 8 years ago

I am writing my OpenStudio measures and then testing them with some test code like shown in the writing openstudio measures guide.

Everything works fine but the time that the code takes to run can be up to 40 seconds, this means that debugging or testing can take a lot longer than it should.

Is it possible to set up the tests in an interactive environment where code snippets can be run one at a time? So that I only need to run the code that I want to test. Is this what Ruby mine does?

Has anyone done this? Any advice would be most appreciated!

Preview: (hide)

Comments

40 seconds sounds like a long time for a measure to run unless it is a reporting measure that runs EnergyPlus or is doing sizing runs. If it is a reporting measure, you can configure the test to save the simulation results so the test can be re-run quickly. We do have a few model measures that can take that longer than a few seconds but only if they are doing more complex operations or are tested on very large models.

David Goldwasser's avatar David Goldwasser  ( 8 years ago )

@DavidGoldWasser it is a modified form of the space and construction wizard and it is most certainly taking more than 40 seconds, isn't this to be expected when you are modifying an existing osm model? I've posted the code here:

and the test file can be seen here

antonszilasi's avatar antonszilasi  ( 8 years ago )

1 Answer

Sort by » oldest newest most voted
6

answered 8 years ago

you could always run your code bit by bit in interactive ruby. Or save parts of it to a ruby script and run that from terminal. For interactive ruby, irb in the command terminal will take you into ruby. Then:

require 'openstudio'

# Helper to load a model in one line
def osload(path)
  translator = OpenStudio::OSVersion::VersionTranslator.new
  ospath = OpenStudio::Path.new(path)
  model = translator.loadModel(ospath)
  if model.empty?
      raise "Path '#{path}' is not a valid path to an OpenStudio Model.  Did you remember to use backlashes / instead of forward slashes \ ?"
  else
      model = model.get
  end  
  return model
end

load_path = "C:/Users/me/path/to/your/model/with/backslashes.osm"
model = osload(load_path)

and then do whatever modeling you want

Preview: (hide)
link

Comments

2

This seems like a good place to plug UnmetHours' resident karma kingpin @Julien Marrec's custom OpenStudio Powershell profile (which I haven't used but looks really handy for this stuff).

ericringold's avatar ericringold  ( 8 years ago )

nice! looking forward to trying that out.

mdahlhausen's avatar mdahlhausen  ( 8 years ago )

Thanks for the plug @Eric Ringold. If you guys try it and hit some roadblocks, don't hesitate to ping me directly or open a github issue.

Julien Marrec's avatar Julien Marrec  ( 8 years ago )

@mdahlhausen

it works thanks! a note however make sure you declare model as a global variable otherwise it doesnt show up in the ruby interactive console so change model to $model

antonszilasi's avatar antonszilasi  ( 8 years ago )

Your Answer

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

Add Answer

Training Workshops

Careers

Question Tools

4 followers

Stats

Asked: 8 years ago

Seen: 499 times

Last updated: Dec 21 '16