lib/to_openstudio/hvac/template.rb in honeybee-openstudio-2.33.1 vs lib/to_openstudio/hvac/template.rb in honeybee-openstudio-2.33.2

- old
+ new

@@ -56,14 +56,15 @@ # get the defaults for the specific system type hvac_defaults = defaults(@hash[:type]) # make the standard applier if @hash[:vintage] - standard = Standard.build(@@vintage_mapper[@hash[:vintage].to_sym]) + standard_id = @@vintage_mapper[@hash[:vintage].to_sym] else - standard = Standard.build(@@vintage_mapper[hvac_defaults[:vintage][:default].to_sym]) + standard_id = @@vintage_mapper[hvac_defaults[:vintage][:default].to_sym] end + standard = Standard.build(standard_id) # get the default equipment type if @hash[:equipment_type] equipment_type = @hash[:equipment_type] else @@ -112,10 +113,83 @@ end end end end + # set the efficiencies of supply components in the air loop + if !os_air_loops.empty? + os_air_loops.each do |os_air_loop| + # set the supply fan efficiency + unless os_air_loop.supplyFan.empty? + s_fan = os_air_loop.supplyFan.get + s_fan = fan_from_component(s_fan) + unless s_fan.nil? + s_fan.setMaximumFlowRate(1) + standard.fan_apply_standard_minimum_motor_efficiency( + s_fan, standard.fan_brake_horsepower(s_fan)) + s_fan.autosizeMaximumFlowRate() + end + end + # set the return fan efficiency + unless os_air_loop.returnFan.empty? + ex_fan = os_air_loop.returnFan.get + ex_fan = fan_from_component(ex_fan) + unless ex_fan.nil? + ex_fan.setMaximumFlowRate(1) + standard.fan_apply_standard_minimum_motor_efficiency( + ex_fan, standard.fan_brake_horsepower(ex_fan)) + ex_fan.autosizeMaximumFlowRate() + end + end + end + end + + # get the boilers and assign the correct efficiency + if equipment_type.to_s.include? 'Boiler' + openstudio_model.getBoilerHotWaters.sort.each do |obj| + obj.setNominalCapacity(40000) # set to a dummy value for the method + standard.boiler_hot_water_apply_efficiency_and_curves(obj) + obj.autosizeNominalCapacity() # set it back to autosize + obj.setName(standard_id + ' Boiler') + end + end + + # get the chillers and assign a reasonable COP from the standard + if equipment_type.to_s.include? 'Chiller' + # set the chiller efficiency + clg_tower_objs = openstudio_model.getCoolingTowerSingleSpeeds + openstudio_model.getChillerElectricEIRs.sort.each do |obj| + obj.setReferenceCapacity(2000000) # set to a dummy value for method + if obj.name.empty? + obj_name = standard_id + ' Chiller' + else + obj_name = obj.name.get + end + standard.chiller_electric_eir_apply_efficiency_and_curves(obj, clg_tower_objs) + obj.autosizeReferenceCapacity() # set it back to autosize + obj.setName(obj_name) + end + end + + # set the efficiency of any gas heaters + if equipment_type.to_s.include? 'GasHeaters' + zones.each do |zon| + zon.equipment.each do |equp| + if !equp.to_ZoneHVACUnitHeater.empty? + unit_heater = equp.to_ZoneHVACUnitHeater.get + coil = unit_heater.heatingCoil + unless coil.to_CoilHeatingGas.empty? + coil = coil.to_CoilHeatingGas.get + coil.setNominalCapacity(10000) # set to a dummy value for method + standard.coil_heating_gas_apply_efficiency_and_curves(coil) + coil.autosizeNominalCapacity() # set it back to autosize + end + end + end + end + end + # assign the economizer type if there's an air loop and the economizer is specified if @hash[:economizer_type] && !os_air_loops.empty? os_air_loops.each do |os_air_loop| oasys = os_air_loop.airLoopHVACOutdoorAirSystem unless oasys.empty? @@ -274,9 +348,21 @@ end end private + + def fan_from_component(fan_component) + # get a detailed fan object from a generic fan HVAC component; will be nil if it's not a fan + if !fan_component.to_FanVariableVolume.empty? + return fan_component.to_FanVariableVolume.get + elsif !fan_component.to_FanConstantVolume.empty? + return fan_component.to_FanConstantVolume.get + elsif !fan_component.to_FanOnOff.empty? + return fan_component.to_FanOnOff.get + end + nil + end def get_existing_erv(os_air_loop) # get an existing heat ecovery unit from an air loop; will be nil if there is none os_air_loop.oaComponents.each do |supply_component| if not supply_component.to_HeatExchangerAirToAirSensibleAndLatent.empty?