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

OpenStudio measure .each does not work?

asked 2018-04-11 10:51:27 -0500

Matt Koch's avatar

updated 2018-04-15 11:28:44 -0500

I am trying to put together a measure that autosizes all the VRF equipment that one can import for LG.

So far, I have the following, but it fails at the first .each it encounters. It says the method does not exist?

Does the makeChoicesArgumentOfWorkspaceObjects not generate a proper Ruby collection for .each to apply?

Also, am I on the right track to accessing the coolingCoil?

  vrfs_in = OpenStudio::Ruleset::makeChoiceArgumentOfWorkspaceObjects("vrfs_in","OS_ZoneHVAC_TerminalUnit_VariableRefrigerantFlow".to_IddObjectType,model,true)

  puts vrfs_in

  puts "Indoor VRF Air Flow"
  vrfs_in.each do vrf_in
    puts vrf_in

    if not vrf_in.autosizedSupplyAirFlowRateDuringCoolingOperation()
      puts vrf_in.supplyAirFlowRateDuringCoolingOperation()
      vrf_in.autosizeSupplyAirFlowRateDuringCoolingOperation()
    else
      puts "indoor cooling air flow autosized already"
    end

    if not vrf_in.autosizedSupplyAirFlowRateDuringHeatingOperation()
      puts vrf_in.supplyAirFlowRateDuringHeatingOperation()
      vrf_in.autosizeSupplyAirFlowRateDuringHeatingOperation()
    else
      puts "indoor heating air flow autosized already"
    end
  end

  puts "Indoor VRF Cooling"
  vrfs_in.each do vrf_in
    cooling_coil = vrf_in.coolingCoil()

    if not cooling_coil.autosizedRatedTotalCoolingCapacity()
      puts cooling_coil.ratedTotalCoolingCapacity()
       cooling_coil.autosizeRatedTotalCoolingCapacity()
    else
      puts "indoor cooling capacity autosized already"
    end
    if not cooling_coil.autosizedRatedAirFlowRate()
      puts cooling_coil.ratedAirFlowRate()
      cooling_coil.autosizeRatedAirFlowRate()
    else
      puts "indoor cooling air flow autosized already"
    end
  end
edit retag flag offensive close merge delete

Comments

1

I think this maybe a syntax error. Have you tried vrfs_in.each do |vrf_in| , instead of leaving it open without the | | encapsulating your vrf_in variable?

gokul's avatar gokul  ( 2018-04-11 11:37:29 -0500 )edit
1

Thanks for the hint, but no, adding the || does not make a difference. It seems to me .each is a class function that ought to be available for vrfs_in but for some reason is not. The only idea I have is that vrfs_in is not a proper Ruby collection? So what would be?

Matt Koch's avatar Matt Koch  ( 2018-04-14 19:44:10 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-04-14 23:59:14 -0500

Matt Koch's avatar

Evidently, instead of

vrfs_in = OpenStudio::Ruleset::makeChoiceArgumentOfWorkspaceObjects("vrfs_in","OS_ZoneHVAC_TerminalUnit_VariableRefrigerantFlow".to_IddObjectType,model,true)

something like

vrfs_in = model.getObjectsByType("OS_AirConditioner_VariableRefrigerantFlow".to_IddObjectType)

seems to generate an ".eachable" Ruby collection.

edit flag offensive delete link more

Comments

Just for the record, I was having trouble with the above, as I could not do much with the vrf.out element in the following:

vrfs_out = model.getObjectsByType("OS_AirConditioner_VariableRefrigerantFlow".to_IddObjectType)
vrfs_out.each do |vrf_out|
  puts vrf_out.ratedTotalCoolingCapacity()
end

However, replacing the first line as follows led to success:.

vrfs_out = model.getAirConditionerVariableRefrigerantFlows

Not sure why these two are not equivalent?

Matt Koch's avatar Matt Koch  ( 2018-04-16 07:12:53 -0500 )edit

Further for the record, it appears that the following is workable as well.

vrfs_out = model.getObjectsByType("OS_AirConditioner_VariableRefrigerantFlow".to_IddObjectType)
vrfs_out.each do |vrf_out|
  vrf_out = vrf_out.to_AirConditionerVariableRefrigerantFlow.get
  puts vrf_out.name
  puts vrf_out.ratedTotalCoolingCapacity()
end

Note the use of the "to_AirConditionerVariableRefrigerantFlow" conversion as well as the associated "get" function.

Matt Koch's avatar Matt Koch  ( 2018-04-16 07:35:24 -0500 )edit

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: 2018-04-11 10:51:27 -0500

Seen: 212 times

Last updated: Apr 14 '18