Access OpenStudio with Ruby console
-
Hi, I'm wondering if is possible to access OpenStudio commands via the ruby console inside SU.
I need to iterate info between SketchUp and EnergyPlus (i.e. Do geometry>do thermal analysis>read results>change geometry based on results>Go again)
Is possible to do this? is there any documentation for that? I don't know how to call the commands of the OpenStudio plugin within SU.Thanks a lot
-
You can execute shell commands from within Ruby.
see: http://phrogz.net/ProgrammingRuby/tut_expressions.html#expressions
scroll down to Miscellaneous ExpressionsOther than that.. there are some guys on here that use Applescript.
Perhaps when the holiday is over, one of the Mac guys will have a better answer for you. -
.
I think DavidBoulder is the guy you may want to talk to. -
.
DavidBoulder posted on the issue of OpenStudioin topic sun elevation and azimut ('OpenStudio' hilited)
-
Bitttttor,
Are you trying to create new geometry as the result of a simulation run, or do you just want to alter existing geometry. For example if your geometry was a box, do you just want to stretch the box, but keep it a box. Trying to think of some ideas.
Dan mentioned in a post to the OpenStudio list that may have been from you that you can look in Ruby console as the plugin runs. Our code is under OpenStudio/lib in the SketchUp plugins. None if it is scrambled, but it isn't documented anywhere either. But if you use a good multi-file text edtior or IDE (I use NetBeans" you could search for specific commands.
In the end, though I think the direction you might want to go is to work with the IDF file outside of OpenStudio vs. trying to do this within OpenStudio/SketchUp. While OpenStudio uses SketchUp as a 3d engine, it doesn't currently use the SketchUp file format. Files are saved to an IDF file which is a text file. Look at the IDF tutorial that came with OpenStudio to learn more about the IDF structure. You could write your own ruby outside of SketchUp to create and alter geometry and run a simulation. Simulation results can come back in a variety of formats such as CSV, HTML, or SQL. Your ruby could read these and trigger changes to the geometry and another simulation run. Whenever you want to you coudl bring an IDF into OpenStudio, but if you aren't going to be manually drawing your building, it may not be the best place for this.
-
To add to my comment above. It is possible that optimization routines will become part of the EnergyPlus workflow in a future release, but I don't have any information on when this might happen, or what features it would include.
If you want to see what ruby code is required to launch EnergyPlus and to read results in you can look at what happens in OpenStudio as a guide.
Below is some example code showing what objects are involved in IDF geometry. The first object is the definition of a thermal zone. The second object is a sample heat transfer surface within that zone. surface refers to a specific "Construction Name" that is also another object in the IDF which I have not included. And that Construction in turn refers to a series of material objects.
Zone, 64AFC3, !- Name 0.0, !- Direction of Relative North {deg} 3.765369, !- X Origin {m} 2.816696, !- Y Origin {m} 0.0, !- Z Origin {m} , !- Type 1; !- Multiplier BuildingSurface;Detailed, A81FC7, !- Name Floor, !- Surface Type Exterior Floor, !- Construction Name 64AFC3, !- Zone Name Ground, !- Outside Boundary Condition , !- Outside Boundary Condition Object NoSun, !- Sun Exposure NoWind, !- Wind Exposure , !- View Factor to Ground 4, !- Number of Vertices 15.450384904933, !- Vertex 1 X-coordinate {m} 17.380089364842, !- Vertex 1 Y-coordinate {m} 0.000000000000, !- Vertex 1 Z-coordinate {m} 19.554902768110, !- Vertex 2 X-coordinate {m} 6.041483942068, !- Vertex 2 Y-coordinate {m} 0.000000000000, !- Vertex 2 Z-coordinate {m} 7.543086307201, !- Vertex 3 X-coordinate {m} 1.693267085172, !- Vertex 3 Y-coordinate {m} 0.000000000000, !- Vertex 3 Z-coordinate {m} 3.438568444024, !- Vertex 4 X-coordinate {m} 13.031872507946, !- Vertex 4 Y-coordinate {m} 0.000000000000; !- Vertex 4 Z-coordinate {m}
Also depending upon your final goals, you may consider another approach. Either manually or programatically create a series of IDF files. On windows you can use the EP-Launch application to patch run a series of simulations. You can then use EP-Compare or ResultsViewer to graph the results and see which geometry represent the optimum condition. While there may be some complex models that would take hours to run, more basic models may take seconds or minutes to run. In the IDF-301 tutorial I describe how to run simulations of a building with different north orientations. In this example I just change a single line of code in each IDF as I'm just changing the building orientation vs. altering the relative geometry of the building. The goal of this was not just to see which orientation is best, but the sensitivity to energy consumption as the orientation moves away from the ideal position.
Hope this helps, let em know if you have any other questions.
David
-
First of all, sorry for the late response, I completely forgot I have posted this question here (I also posted it in other places)
And thanks very much to Dan and David, your answers helped me a lot. What I'm trying to do is relatively simple but I haven't found the appropriate environment/language develop it. This work is part of a research project, and if you have time help me it would be great.In terms of 3d geometry, the exercise is a box with two or tree divisions (a basic house) and the optimization will be done in the facades, playing in 2d with openings to achieve some internal conditions (temperature/humidity). The rules under which these opening are changed are based in a range of other factors so they should be scripted in some code (I have some tests in Processing)
I'm not an expert programmer so I started looking for a 3d environment where I could both script and check the results without much bridges, ecotect/lua is a good example but it is somehow questioned in the quality of its results (is this true??). Designbuilder doesn't have an embedded scripting tool so ruby/sketchup was an open possibility... but again, it looks kind of complex to manipulate openstudio with ruby, so I decided to turn to the core and look directly to energyplus erl... after all I don't need most of the features of the usual 3d software. If I'm not wrong erl is a simplified language for E+ input file which can be read as .txt files. What part of the documentation (it is very extended) do you recommend to begin with? what do you think is better in my case? to stick with and environment like ecotect/lua or sketchup/ruby/openstudio? or to try a bridge between for example Processing/Java/E+? If I decide to go with the second (I think is better even though is more complex), could you show me some guidelines?
Thanks a lot, I'll be looking forward for your answer.
-
I'm starting to realize what implies to code directly over the IDFs. Please correct me if I'm wrong.
All the different input generator softwares work more or less by defining these files and the analysis is done after in EP. So the main problem (for me) of working this way is that you can't change the geometry directly scripting with ERL in the IDF, because you have to define the input, then run the simulation, read the results and then make the comparisons and changes. Is not possible to automate this procedure directly by ERL, so you need something like BCVTB (MatLab) to maintain the logic operation outside and use EP as simulation engine. In this sense ecotect/lua presents a more basic but integrated environment where you can perform both (logic + simulation) in one major framework, and this is also possible in SU/OpenStudio/Ruby with some understanding of the procedures. Both matlab and ecotect have extensive documentation regarding this specific functionality, but SU has a major advantage by being a free and user friendly software... I know is a lot to ask but it would be great to have a wiki regarding this issues some day, but maybe there is only few people interested in doing stuff like this. Thanks for OpenStudio, is a major step forward. -
I think I found something for you. Genopt is an optimization application that can work with an simulation which takes text files as an input and gives results as a text file. Below is a link to a tutorial on Genops and energy plus. I think this will help you. I have also forwarded your questions to some other people here. If they come up with some other solutions or idea's I'll let you know.
http://sites.google.com/site/genopttutorial/David
-
Thanks !!!
Advertisement