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

Revision history [back]

require 'openstudio'

m = OpenStudio::Model::Model.new

terminal = OpenStudio::Model::ZoneHVACTerminalUnitVariableRefrigerantFlow.new(m)

# The default fan type for the terminal in OS is FanOnOff
# but if you want to see what type your terminal has you could do this
# I think FanConstantVolume is also allowed
puts terminal.supplyAirFan.briefDescription

# or this
puts terminal.iddObject.name

# this is how you "cast" the generic HVAC component "to_FanOnOff"
# note that the "get" will cause you program to crash 
# if the fan type is not FanOnOff
fan = terminal.supplyAirFan.to_FanOnOff.get

# you can check if the casting was successful before calling get like this
# this is a way to prevent a crash in your program if you don't know what type you have
optional_fan = terminal.supplyAirFan.to_FanOnOff

if ! optional_fan.empty? 
  fan = optional_fan.get
end

# might also be
#fan = terminal.supplyAirFan.to_FanConstantVolume.get

fan.setPressureRise(300)
fan.setFanEfficiency(0.5)
fan.setMotorEfficiency(0.75)