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

OpenStudio clean up routine after changing system type for several zones

asked 2015-04-08 06:36:34 -0500

updated 2015-04-08 06:38:50 -0500

I wrote a measure to switch selected zones from central systems to single-zone system. The central system can have water coils, both cooling and heating, and therefore could be attached to a chiller and/or boiler loop. The chiller loop can be connected to a condenser water loop.

Basically, before doing anything, I'm storing the pre-existing airloops. Then, after switching the selected zones to another system type, those zones are no longer on the pre-existing airloops.

What I'd like to do is to clean up any unused Loops after that. My idea is:

  • loop on Pre-existing AirLoops, delete all those don't have any zones anymore but before deletion check if connected to boiler and/or chiller loops and store those associated chiller and boiler loops.
  • Loop on associated chiller loops and if demand components are linked to no air loop, delete chiller loop, but before deletion check if chiller is connected to a condenser water loop and store it
  • Loop on associated condenser water loops and if not linked to any other demand component, delete it
  • Do something similar to associated hot water loops.

I'm in the middle of writing this cleanup routine, and it's proving pretty time consuming.

Considering this seems like a legitimate and, I think, quite often useful routine, I think there are good chances somebody better at Ruby/OS Measures has already written it, but I haven't found it yet.

Does anybody know if that's already been done, so I don't have to reinvent the wheel?

edit retag flag offensive close merge delete

Comments

My first stab at it here (starting line 267 till line 439 - missing boiler section, as well as integrating chiller.secondaryPlantLoop to get the condenser loops as per @David Goldwasser 's answer here)

Julien Marrec's avatar Julien Marrec  ( 2015-04-08 13:55:20 -0500 )edit

I have the start of a measure to remove orphan objects and unused resources, but so far it only focuses on envelope, internal loads, schedules, and constructions. Ideally this will eventually would go through HVAC as well. It is possible that @aparker or @Kyle Benne have some code to do this.

Instead of storing the pre-existing loops, maybe make it generic to work on any model.

  • Loop through air loops and remove them if no thermal zones
  • Loop through plant loops and remove if no demand objects
  • Do second pass through plant loop for secondary loops.
David Goldwasser's avatar David Goldwasser  ( 2015-04-08 13:59:31 -0500 )edit

I did it this way because of two things:

  • Speed, by avoiding to loop on everything. It's irrelevant here because it runs fast but I've picked up this habit of avoiding costly loops when I can
  • Make sure I don't remove something that wasn't affected. Now, that's also somewhat irrelevant as long as you run your measure only once your "baseline" model is ready. But if doing it in "Apply Now", you could have loops that you started and didn't finish that you would want not removed.
Julien Marrec's avatar Julien Marrec  ( 2015-04-09 02:17:26 -0500 )edit

@Julien Marrec Sometimes I wonder if the API should be doing this kind of clean up for you, but to this point I have resisted the urge because I think removing entire systems as a side effect of removing a component would be a little surprising. I would certainly reconsider if there was a strong feeling from a number of knowledgeable users. Maybe just some supporting methods in the API would be good. Something like AirLoopHVAC::removeUnusedSystems().

Kyle Benne's avatar Kyle Benne  ( 2015-04-14 21:20:16 -0500 )edit

I'd second the supporting method removeUnusedSystems(). I've got a draft of it here. Missing the boiler section that I didn't need for this specific project.

Julien Marrec's avatar Julien Marrec  ( 2015-04-15 03:07:32 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-04-08 14:23:31 -0500

updated 2015-04-08 14:40:44 -0500

If you don't need to save anything from the original system you can use the heavy handed approach that is used on the AEDG HVAC measures. Everything is removed then the new systems is added. This is in the 'OsLib_HVAC.rb' file in the resources directory. It is run before new systems are added.

def OsLib_HVAC.removeEquipment(model, runner)

airloops = model.getAirLoopHVACs
plantLoops = model.getPlantLoops
zones = model.getThermalZones

# remove all airloops 
airloops.each do |air_loop|
  air_loop.remove
end

# remove all zone equipment except zone exhaust fans
zones.each do |zone|
  zone.equipment.each do |equip|
    if equip.to_FanZoneExhaust.is_initialized
    else  
      equip.remove
    end
  end
end       

# remove plant loops
plantLoops.each do |plantLoop|
  # get the demand components and see if water use connection, then save it
  # notify user with info statement if supply side of plant loop had heat exchanger for refrigeration
  usedForSHWorRefrigeration = false
  plantLoop.demandComponents.each do |comp| #AP code to check your comments above
    if comp.to_WaterUseConnections.is_initialized or comp.to_CoilWaterHeatingDesuperheater.is_initialized
      usedForSHWorRefrigeration = true
    end
  end
  if usedForSHWorRefrigeration == false
    plantLoop.remove
  else
    runner.registerWarning("#{plantLoop.name} is used for SHW or refrigeration heat reclaim.  Loop will not be deleted")
  end
end #next plantLoop

end # end of def
edit flag offensive delete link more

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

1 follower

Stats

Asked: 2015-04-08 06:36:34 -0500

Seen: 325 times

Last updated: Apr 08 '15