First time here? Check our help page!
4

How do you fix orphaned objects in OpenStudio

Wondering what your tricks are to fix a situation where OpenStudio orphans an object? For example, as of version 1.5.0 if you remove a water coil in a certain way it can be orphaned and cause OS to crash during some actions. This is related to a known bug in OS, but I'm curious if you've experienced other similar bugs and what your fix was?

MatthewSteen's avatar
10.1k
MatthewSteen
asked 2014-10-30 17:10:04 -0500
__AmirRoth__'s avatar
4.4k
__AmirRoth__
updated 2015-11-09 14:11:18 -0500
edit flag offensive 0 remove flag close merge delete

Comments

It still happens with cooling coils, I deleted it from the air loop and had to put it back in the plant loop and delete it again to remove it from the osm file.

naudejch's avatar naudejch (2022-09-10 08:30:14 -0500) edit
add a comment see more comments

3 Answers

8

I would write an OpenStudio Measure to remove these orphaned objects. You can run the Measure on your model via "Components & Measures > Apply Measure Now" and see the impact of the Measure before saving the edited model.

Here is the ruby code you to put inside the run method in measure.rb:

# Remove orphaned hot water heating coils
model.getCoilHeatingWaters.each do |coil|
  if coil.airLoopHVAC.is_initialized and coil.plantLoop.is_initialized
    next # Ignore coils that are already connected properly
  elsif coil.plantLoop.is_initialized
    next # Ignore hot water coils that are already connected properly inside air terminals
  else
    coil.remove
    runner.registerInfo("Removed an orphaned hot water coil called #{coil.name.get}")
  end
end    

# Remove orphaned chilled water cooling coils
model.getCoilCoolingWaters.each do |coil|
  if coil.airLoopHVAC.is_initialized and coil.plantLoop.is_initialized
    next # Ignore coils that are already connected properly
  else
    coil.remove
    runner.registerInfo("Removed an orphaned chilled water coil called #{coil.name.get}")
  end
end        

# Remove orphaned water coil controllers (for hot and chilled water coils)
model.getControllerWaterCoils.each do |controller_water_coil|
  controller_used = false
  model.getCoilHeatingWaters.each do |coil|
    if coil.controllerWaterCoil.is_initialized
      if coil.controllerWaterCoil.get == controller_water_coil
        controller_used = true
      end
    end
  end
  model.getCoilCoolingWaters.each do |coil|
    if coil.controllerWaterCoil.is_initialized
      if coil.controllerWaterCoil.get == controller_water_coil
        controller_used = true
      end
    end
  end      
  # Remove unused water coil controllers
  if controller_used == false
    controller_water_coil.remove
    runner.registerInfo("Removed #{controller_water_coil.name.get} because it is unused")
  end
end
aparker's avatar
8.2k
aparker
answered 2014-10-30 21:37:03 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
2

I just uploaded a measure to do this very thing, although the current version doesn't address orphan HVAC objects. Looks like I need to take @aparker's code and extend the measure. But until then it works for internal loads and surfaces. It also optionally allows you to remove unused resources from the model.

The OpenStudio user documentation troubleshooting page has additional details and screenshots of the measure.

David Goldwasser's avatar
20.4k
David Goldwasser
answered 2014-11-26 13:19:59 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
1

I've used a kind of brute force method in the past, by directly manipulating the .osm file, but be very careful in doing so, you can break your model in all kinds of ways! Caveat emptor definitely applies, and I would definitely make a copy of the file before doing any manual manipulation.

In my case, it happened to be with some orphaned luminaires.

You can usually narrow down your search to the few objects you suspect to be the orphans based on the behaviour of your model, or maybe error messages you are getting. I've then taken the object ID text, and done a search in the file for that string of characters to see if it is associated with any other objects. If the object ID is being used by another object, you could safely assume that that object is not your orphan.

In the case of coils, the object ID would show up in a NodeList somewhere if it is not orphaned.

Again, I can't stress this enough: BE CAREFUL doing it this way.

Benjamin's avatar
1.1k
Benjamin
answered 2014-10-31 15:33:20 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments