First time here? Check our help page!
2

how to run a simulation using python

Hi,

I have installed openstudio 3.7 from pipy and I would like to have a sample python script that runs a simulation directly from my python IDE. Model,osm and weather-file both reside in the same folder.

As I couldn't find the python-bindings api reference, I'm a bit lost as I was unable to find a "run" or "run_simulation" method as in earlier versions.

So both (reference python bindings 3.7 and example) would be highly appreciated.

Thank you

oprislan's avatar
23
oprislan
asked 2023-12-27 12:10:59 -0500
Aaron Boranian's avatar
14.1k
Aaron Boranian
updated 2023-12-28 09:48:03 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

3

In order to actually run a simulation, you must have the openstudio SDK installed separately (get it from here), so you can use the Command Line Interface (CLI) openstudio(.exe). Make a syscall to it once you've prepared your OSM model and Workflow JSON (workflow.osw).

import subprocess
subprocess.run(['openstudio', 'run', '-w', 'workflow.osw'])

example workflow.osw:

{
  "weather_file": "weather.epw",
  "seed_file": "model.osm",
}
Julien Marrec's avatar
29.7k
Julien Marrec
answered 2023-12-29 09:19:12 -0500
edit flag offensive 0 remove flag delete link

Comments

Thank you Julien, it works!

oprislan's avatar oprislan (2024-01-07 04:31:09 -0500) edit
add a comment see more comments