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

ZoneHVAC_TerminalUnit_VariableRefrigerantFlow supplyAirFan in OS measure

asked 2018-04-15 13:44:12 -0500

Matt Koch gravatar image

updated 2018-04-16 06:58:35 -0500

So, the following seems to work reasonably well:

vrfs_in = model.getZoneHVACTerminalUnitVariableRefrigerantFlows
vrfs_in.each do |vrf_in|
  puts vrf_in.name
  cooling_coil = vrf_in.coolingCoil().get
  puts cooling_coil.name
end

However, the following fails, stating that the get method is undefined:

vrfs_in = model.getZoneHVACTerminalUnitVariableRefrigerantFlows
vrfs_in.each do |vrf_in|
  puts vrf_in.name
  supply_air_fan = vrf_in.supplyAirFan().get
end

Yet, both coolingCoil() and supplyAirFan() appear to have identical "status" per this reference, and so I would have thought they both can be treated the same way? Why does it fail for supplyAirFan() but not for coolingCoil()?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2018-04-15 14:13:08 -0500

updated 2018-04-15 14:16:11 -0500

The documentation page you referenced is from version 1.8.3, but I suspect you're using a version of OpenStudio that's post-v2.3.1.

The latest (v2.5.0) documentation shows that coolingCoil returns an OptionalCoilCoolingVariableRefrigerantFlow object, for which you get the actual CoilCOolingVariableRefrigerantFlow object by calling .get, as you have done.

However, the supplyAirFan method returns an HVACComponent object (not an "optional" type), which does not respond to the .get method, and why you receive the 'undefined method' error.

So your code will work if you just do supply_air_fan = vrf_in.supplyAirFan (no .get). Note, since you then have an HVACComponent, in order to have access to specific fan object methods, you'll need to cast it to the appropriate fan type by checking, e.g. if supply_air_fan.to_FanOnOff.is_initialized? and then .get that object type.

PS: here is where/when the vrf coils were changed to return optional.

edit flag offensive delete link more

Comments

I realized the error of my ways on the drive in to work this morning and would have gone hunting for the "to_FanOnOff" function. Image my joy when you provided that function in your answer! The following works great, thank you again!

vrfs_in = model.getZoneHVACTerminalUnitVariableRefrigerantFlows
vrfs_in.each do |vrf_in|
  supply_air_fan = vrf_in.supplyAirFan().to_FanOnOff.get
  puts supply_air_fan.name
  puts supply_air_fan.maximumFlowRate()
end
Matt Koch gravatar imageMatt Koch ( 2018-04-16 07:05:47 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

 



Question Tools

2 followers

Stats

Asked: 2018-04-15 13:44:12 -0500

Seen: 37 times

Last updated: Apr 15