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

OSW for multiple seed models

asked 2018-06-22 09:21:16 -0500

antonszilasi's avatar

updated 2018-06-22 09:35:11 -0500

I would like to create an Open Studio Workflow json which contains multiple seed models and the application of multiple measures to each seed model to generate a parametric study.

Perhaps I am missing some documentation but the file "generate_workflows_parametric.rb"in the OpenStudio_CLI_Template which is the closest to what I need. Only demostrates how to create a OSW for one seed model, where can I find example code to generate an OSW for multiple seed models?

Or am I mistaken and one OSW should only correspond to one seed model, and therefore multiple seed models should be represented by a folder containing many subfolders which contain an OSW for each seed model like the pictures below ---

Many OSWs with each representing a seed model image description Inside the first folder image description The OSW inside the first folder - representing a workflow for a seed model image description

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
4

answered 2018-06-22 13:15:59 -0500

updated 2018-06-22 13:34:21 -0500

One model, one osw.

Documentation for the osw structure found here and schema here.

You can build an osw programmatically using the WorkflowJSON object

As an example, this is what your script might look like:

# the logic in the parametric script is built around making an .osw file
def make_osw(run_name, osm_filepath, epw_filepath, model_measure_steps = [], energyplus_measure_steps = [], reporting_measure_steps = [])
  puts "Making directory #{run_name}"
  FileUtils.mkdir "workflows/#{run_name}"
  osw_filepath = OpenStudio::Path.new("#{Dir.pwd}/workflows/#{run_name}/workflow.osw")
  osw = OpenStudio::WorkflowJSON.new
  osw.setSeedFile(osm_filepath)
  osw.setWeatherFile(epw_filepath)
  if !model_measure_steps.empty?
    measure_type = OpenStudio::MeasureType.new("ModelMeasure")
    osw.setMeasureSteps(measure_type, model_measure_steps)
  end
  if !energyplus_measure_steps.empty?
    measure_type = OpenStudio::MeasureType.new("EnergyPlusMeasure")
    osw.setMeasureSteps(measure_type, energyplus_measure_steps)
  end
  if !reporting_measure_steps.empty?
    measure_type = OpenStudio::MeasureType.new("ReportingMeasure")
    osw.setMeasureSteps(measure_type, reporting_measure_steps)
  end
  osw.saveAs(osw_filepath)
  puts "#{run_name} osw written"
  return true
end

# define measures to add to the model
measure1 = OpenStudio::MeasureStep.new("measure1")
measure1.setArgument("arg1","some string argument value")

measure2 = OpenStudio::MeasureStep.new("measure2")
measure2.setArgument("arg1",0.5)

# path to an epw file and a list of paths to the multiple seed models
# use ruby Dir.glob or related script to pull all .osms paths in a directory into an array
# e.g. osm_files = Dir.glob(File.join("seed_models/**","*.osm"))
epw_path = "path/to/epw/tmy3.epw"
model_paths = ["/path/to/file/seed1.osm","/path/to/file/seed2.osm","/path/to/file/seed3.osm"]

# convert them to OpenStudio::Path objects
epw_path = OpenStudio::Path.new(epw_path)
model_paths = model_paths.map {|x| OpenStudio::Path.new(x)}

model_paths.each do |path|
  run_name = path.to_s.split("/")[-1].chomp(".osm") + "_measure1and2"
  makeOSW(run_name, path, epw_path, [measure1, measure2], [], [])
end

Alternatively, you could adjust the measure so instead of making a directory for each .osw, it names each .osw and dumps them all in the same directory

edit flag offensive delete link more

Comments

Just what I was looking for to set up better unit tests. Thanks!

Phylroy Lopez's avatar Phylroy Lopez  ( 2019-09-05 16:34:25 -0500 )edit
3

answered 2018-06-23 08:07:04 -0500

I couldn't tell from your post, but if you're in the situation that you want to run the same measures on different seed models, you can accomplish this using a single OSW.

The trick is to leave the seed_file out of the OSW entirely. Then have the first measure in your OSW be a measure that takes in a path to your seed OSM of interest and loads it into a model like so:

translator = OpenStudio::OSVersion::VersionTranslator.new
path = OpenStudio::Path.new(path_to_osm)
model = translator.loadModel(path)
assert((not model.empty?))
model = model.get

This would allow you to call the same OSW over and over but with the argument changing to different seed models.

edit flag offensive delete link more

Comments

can a similar thing be done with the weather_file? would love to run parametrics on different buildings (seed_file) in different locatios (weather_file).

Determinant's avatar Determinant  ( 2018-09-07 21:44:19 -0500 )edit

Yes, definitely. You can leave the weather file out of the OSW and apply it via an OS measure.

shorowit's avatar shorowit  ( 2022-09-19 19:50:56 -0500 )edit
1

@Determinant, if you are going to sweep across weather files I recommend adding the Change Building Location measure to your workflow, instead of the weather file field in the OSW. In addition to changing the weather file, the measure, changes design days, sets the water main temperatures, and sets the ASHRAE climate zone (important if you plan to run measures that use OpenStudio Standards gem to assign climate zone specific instructions). The measure expects .stat and .ddy with .epw.

David Goldwasser's avatar David Goldwasser  ( 2022-09-20 18:36:40 -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

3 followers

Stats

Asked: 2018-06-22 09:21:16 -0500

Seen: 606 times

Last updated: Sep 19 '22