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

does openstudio reverse translator only collect curve objects?

asked 2018-06-05 14:57:30 -0500

Matt Koch's avatar

updated 2018-06-05 19:30:43 -0500

So, just curious. The file vrf_library.idf contains a whole bunch of EnergyPlus objects.

However, I observe the following:

library = OpenStudio::Workspace::load("#{File.dirname(__FILE__)}/resources/vrf_library.idf").get

# UNFORTUNATELY, the following ONLY captures curves from the library file!!!

reverse_translator = OpenStudio::EnergyPlus::ReverseTranslator.new
library_model = reverse_translator.translateWorkspace(library)

puts "Start Translation!"
puts library_model
puts "Stop Translation"

library_curve_linear = library_model.getObjectByTypeAndName(OpenStudio::Model::CurveLinear::iddObjectType,"OS Default Cooling Cycling").get.to_CurveLinear.get
library_curve_cubic = library_model.getObjectByTypeAndName(OpenStudio::Model::CurveCubic::iddObjectType,"OS Default Heating Combination").get.to_CurveCubic.get
library_curve_biquadratic = library_model.getObjectByTypeAndName(OpenStudio::Model::CurveBiquadratic::iddObjectType,"OS Default HR Capacity").get.to_CurveBiquadratic.get

puts "Start Curve Linear!"
puts library_curve_linear
puts "Stop Curve Linear!"

puts "Start Curve Cubic!"
puts library_curve_cubic
puts "Stop Curve cubic!"

puts "Start Curve BiQuadratic!"
puts library_curve_biquadratic
puts "Stop Curve BiQuadratic!"

The line "puts library_model" literally only prints curves, none of the other objects. Is that an inherent limitation in OpenStudio?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2018-06-06 08:11:01 -0500

TL;DR / Your specific case

No, it collects more than just curves, including most (if not all) of the geometry, as well as a bunch of other objects (eg: here's the ReverseTranslator I wrote for Generator:MicroTurbine when I added it to the SDK).

You're loading a file where the only objects that are able to be reverse translated are the curves, that's all.


What objects are Reverse Translated?

The openstudiocore/src/energyplus/CMakeLists.txt is a good place to start looking at which classes appear to have a ReverseTranslator method implemented: see CMakeLists.txt#L395:L519.

That being said, it's not because a given object has a ReverseTranslator method that it is actually used by OpenStudio... In fact, ALL of the methods ReverseTranslator::translateClassOfObject are private, and they are called or not by the public method ReverseTranslator::translateWorkspace. That also means you cannot even force OpenStudio to try to translate something that does have a RT written out while it's not called by translateWorkspace

To see what is actually reverse translated (or trying to be reverse translated at least), you need to look at ReverseTranslator.cpp#L271:L993 and look for actual calls to translateClassOfObject.


Example

This probably seems still a bit obscure, so to illustrate let's take an example: AirLoopHVAC.

CMakeLists.txt#L395 will build the file ReverseTranslator/ReverseTranslateAirLoopHVAC.cpp which holds a single method called ReverseTranslator::translateAirLoopHVAC.

As you can see translateAirLoopHVAC actually exists, and has about 400 lines of code.

Yet it will never actually be called by the ReverseTranslator::translateWorkspace method, see ReverseTranslator.cpp#L273:L277, you'll see that it is commented out, so when it encounters an AirLoopHVAC it just does nothing.

You might wonder why there are 400 lines of code that just aren't used.

If you want the Reverse Translation of an AirLoopHVAC to work, then you need to handle all possible objects that may appear on an AirLoopHVAC, which means write a ReverseTranslator for each and every single one, which isn't the case currently.

General comments

Implementing ReverseTranslation of all IDF objects that are implemented in OpenStudio SDK currently is not impossible (I don't think it'd even be an awfully complicated task), but it would be quite daunting to do everything in terms of man-hours: you need to write it out, and if you do write it out then you probably want to add unit tests to ensure it does work and will keep working in time.

I don't think there was ever any funding for ReverseTranslation, and it imposes more maintenance, so that's probably why it isn't near complete right now.

(Building ReverseTranslation of all objects in the SDK has been a fantasy of mine for quite some time as it would allow almost perfect round-trip to and from IDF, but obviously the problem is purely monetary... I'd love to be able to load E+ examples files directly in OpenStudio for example).

edit flag offensive delete link more

Comments

@Julien Marrec How many hours you estimate for that?

Avi's avatar Avi  ( 2018-06-06 08:52:11 -0500 )edit

Thank you kindly, Julien Marrec. The links you provide indeed do not mention anything at all about VariableRefrigerantFlow components, and apparently not even something as simple as a FanOnOff. So, as you suggest, I just happen to have a case where the reverse translator is just "blind" to most of my .idf entries - the curves are indeed the only common denominator.

Matt Koch's avatar Matt Koch  ( 2018-06-06 09:15:51 -0500 )edit

@Avi, I'm not sure really. A metric shit-ton perhaps? In more seriousness, this would require spending time figuring out which RT are missing (and then there are probably some unknown unknowns on top of it). That part could be done in a couple of hours max in a naive way by parsing the src/model/ classes and trying to match them to the src/energyplus/ReverseTranslator/ classes.

Julien Marrec's avatar Julien Marrec  ( 2018-06-06 16:14:01 -0500 )edit

Then to get a ballpark I'd guesstimate something like 4 hours on average per class to write the RT and a unit test (for the object only, not taking interaction with other objects etc). That's a guess, take it like a physicist: the order of magnitude is the important part here...

Julien Marrec's avatar Julien Marrec  ( 2018-06-06 16:14:15 -0500 )edit

I'm swamped lately, so I won't spend the two hours on this exercise, but if you do I'm interested. :)

Julien Marrec's avatar Julien Marrec  ( 2018-06-06 16:14:41 -0500 )edit

Well, it took me half an hour to estimate it. See the Ipython notebook (you can just view it, no need to run): https://gist.github.com/jmarrec/c7bc3...

So if you assume 1/hr/class missing: about 300 hours, if you assume 4hr/class: 1200 hours.

Julien Marrec's avatar Julien Marrec  ( 2018-06-06 16:44:39 -0500 )edit

It'd be interesting to pick two objects (a simple one, and an awful one like VRF) and track the time needed to implement the RT + a unit test (you can skip child objects that don't have a RT, since one the RT for it is implemented it's really simple to add it to the parent) to see how much time that really takes on average. This time I will not spare the time, I'm off to sleep. (This discussion should really be on UH slack (see here on how to join), I'm polluting the comment area...

Julien Marrec's avatar Julien Marrec  ( 2018-06-06 16:49:26 -0500 )edit

@Julien Marrec I am tempted to take it on since I feel like contributing some. I will try to understand how big is it since I am not sure it is not out of my league.

Avi's avatar Avi  ( 2018-06-07 00:34:37 -0500 )edit

Feel free to swing by the Slack channel if you need some pointers getting started (setting up the project to compile, general ideas on how to implement a RT, etc). I'm usually on it from 9 AM to 6 PM CET.

Julien Marrec's avatar Julien Marrec  ( 2018-06-07 02:17:50 -0500 )edit

@Matt Koch, please mark the answer as accepted if that solved your problem, so the thread gets marked as resolved.

Julien Marrec's avatar Julien Marrec  ( 2018-06-07 03:23:49 -0500 )edit

@Matt Koch, in case it's helpful to you in the future on the OS website there is a quick summary of import/export options.

aparker's avatar aparker  ( 2018-06-10 15:23:54 -0500 )edit

The Reverse Translator isn't very full featured because in the early days of OS, very few people were using EnergyPlus, which made import of IDFs much less important.

aparker's avatar aparker  ( 2018-06-10 15:25:23 -0500 )edit

It seems to me Curve:Exponent is another object missing from the reverse translator at present.

So, in general, I am using IDF format to create and import equipment libraries. Couldn't one achieve the same using OSM format? After all, the OSM contents are ASCII as well and very similar to IDF in format. If so, what (other than replacing .idf with .osm) is the equivalent to:

library_file = OpenStudio::Workspace::load("#{File.dirname(__FILE__)}/resources/vrf_library.idf").get
Matt Koch's avatar Matt Koch  ( 2018-06-12 16:16:21 -0500 )edit

Yes, you can absolutely use .osm files as a library source. The easiest way to do this is to make a new model in the OS App, add/edit all the curves/whatever you want, and save the model. Then, under preferences > change default libraries > add, pick your .osm library. Until a few versions ago, OS wouldn't load HVAC objects from the library, but now it does.

aparker's avatar aparker  ( 2018-06-12 16:21:35 -0500 )edit

Assuming I want to reuse my .idf file, could I just change the extension from .idf to .osm, and then inside the file, add an OS: in front of all objects? Then use the following?

library_file = OpenStudio::Workspace::load("#{File.dirname(__FILE__)}/resources/vrf_library.osm").get
test = library_file.getObjectsByType("OS_ZoneHVAC_TerminalUnit_VariableRefrigerantFlow".to_IddObjectType)
Matt Koch's avatar Matt Koch  ( 2018-06-12 16:33:16 -0500 )edit

Matt, adding "OS:" in front is definitely not going to work. There are differences in the E+ .idd and the OS .idd, the first of which is that all objects have an extra "handle" field at the first position. Also, child objects are referenced by their handle and not their name. Also, in some cases, there are extra objects that don't exist in one or the other format (eg: BranchList etc is a purely E+ convention, in OSM it relies on Connection objects). Generally speaking, editing an OSM in a text editor, unless doing something very basic is definitely not safe and will bite you at some point.

Julien Marrec's avatar Julien Marrec  ( 2018-06-13 02:27:54 -0500 )edit

Yes, thank you, I realized that myself yesterday and decided I did not want to mess with handles. I also have gone too far down the road of .idf import now, so I developed a workaround to get my Curve:Exponent recognized, since the reverse translator does not do that. That was the only remaining hurdle to success on my side. I can now import a complete custom VRF system (indoor and outdoor) from an .idf file, which became necessary because Daikin does not offer such - they only do it for Trace-700 and eQUEST. How well it will work in terms of producing reasonable results, only time can tell.

Matt Koch's avatar Matt Koch  ( 2018-06-13 07:53:57 -0500 )edit

Next time you want to do that, you should create an OSM library instead, you'll spend a bit more time creating the library perhaps, but import will be seemless from there.

Julien Marrec's avatar Julien Marrec  ( 2018-06-13 09:53:23 -0500 )edit

Understood - is the way to do that to create a new .OSM file from within the OpenStudio application, then e.g. go straight to the HVAC tab and add, e.g. VRF systems and VRF terminals, edit the fields as necessary and save that file? And that then becomes the library?

Matt Koch's avatar Matt Koch  ( 2018-06-13 10:07:56 -0500 )edit

Yes, that's exactly it.

aparker's avatar aparker  ( 2018-06-13 15:02:52 -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

Careers

Question Tools

2 followers

Stats

Asked: 2018-06-05 14:57:30 -0500

Seen: 348 times

Last updated: Jun 06 '18