lib/openstudio-standards/standards/necb/NECB2011/lighting.rb in openstudio-standards-0.2.12.rc4 vs lib/openstudio-standards/standards/necb/NECB2011/lighting.rb in openstudio-standards-0.2.12.rc5

- old
+ new

@@ -1,26 +1,56 @@ class NECB2011 - def apply_standard_lights(set_lights, space_type, space_type_properties) + + def apply_standard_lights(set_lights: true, + space_type:, space_type_properties:, + lights_type: 'NECB_Default', + lights_scale: 1.0) + lights_have_info = false lighting_per_area = space_type_properties['lighting_per_area'].to_f lighting_per_person = space_type_properties['lighting_per_person'].to_f lights_frac_to_return_air = space_type_properties['lighting_fraction_to_return_air'].to_f lights_frac_radiant = space_type_properties['lighting_fraction_radiant'].to_f lights_frac_visible = space_type_properties['lighting_fraction_visible'].to_f lights_frac_replaceable = space_type_properties['lighting_fraction_replaceable'].to_f - lights_have_info = true unless lighting_per_area.zero? - lights_have_info = true unless lighting_per_person.zero? + lights_have_info = true if !lighting_per_area.zero? or !lighting_per_person.zero? + + ##### NOTE: Reference for LED lighting's return air, radiant, and visible fraction values is: page 142, NREL (2014), "Proven Energy-Saving Technologies for Commercial Properties", available at https://www.nrel.gov/docs/fy15osti/63807.pdf + if lights_type == 'LED' + led_lights_have_info = false + led_spacetype_data = @standards_data['tables']['led_lighting_data']['table'] + standards_building_type = space_type.standardsBuildingType.is_initialized ? space_type.standardsBuildingType.get : nil + standards_space_type = space_type.standardsSpaceType.is_initialized ? space_type.standardsSpaceType.get : nil + led_space_type_properties = led_spacetype_data.detect { |s| (s['building_type'] == standards_building_type) && (s['space_type'] == standards_space_type) } + if led_space_type_properties.nil? + raise("#{standards_building_type} for #{standards_space_type} was not found please verify the led lighting database names match the space type names.") + end + + lighting_per_area_led_lighting = led_space_type_properties['lighting_per_area'].to_f + lights_frac_to_return_air_led_lighting = led_space_type_properties['lighting_fraction_to_return_air'].to_f + lights_frac_radiant_led_lighting = led_space_type_properties['lighting_fraction_radiant'].to_f + lights_frac_visible_led_lighting = led_space_type_properties['lighting_fraction_visible'].to_f + led_lights_have_info = true unless lighting_per_area_led_lighting.zero? + + end + if set_lights && lights_have_info # Remove all but the first instance instances = space_type.lights.sort if instances.size.zero? definition = OpenStudio::Model::LightsDefinition.new(space_type.model) - definition.setName("#{space_type.name} Lights Definition") + if lights_type == 'NECB_Default' + definition.setName("#{space_type.name} Lights Definition") + elsif lights_type == 'LED' + definition.setName("#{space_type.name} Lights Definition - LED lighting") + end + # puts definition.name().to_s instance = OpenStudio::Model::Lights.new(definition) instance.setName("#{space_type.name} Lights") + # puts instance.name.to_s instance.setSpaceType(space_type) OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} had no lights, one has been created.") instances << instance elsif instances.size > 1 instances.each_with_index do |inst, i| @@ -32,24 +62,43 @@ # Modify the definition of the instance space_type.lights.sort.each do |inst| definition = inst.lightsDefinition unless lighting_per_area.zero? - set_lighting_per_area(space_type, definition, lighting_per_area) + if lights_type == 'NECB_Default' + set_lighting_per_area(space_type, definition, lighting_per_area) + elsif lights_type == 'LED' + set_lighting_per_area_led_lighting(space_type: space_type, + definition: definition, + lighting_per_area_led_lighting: lighting_per_area_led_lighting, + lights_scale: lights_scale) + end end unless lighting_per_person.zero? definition.setWattsperPerson(OpenStudio.convert(lighting_per_person.to_f, 'W/person', 'W/person').get) OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.SpaceType', "#{space_type.name} set lighting to #{lighting_per_person} W/person.") end unless lights_frac_to_return_air.zero? - definition.setReturnAirFraction(lights_frac_to_return_air) + if lights_type == 'NECB_Default' + definition.setReturnAirFraction(lights_frac_to_return_air) + elsif lights_type == 'LED' + definition.setReturnAirFraction(lights_frac_to_return_air_led_lighting) + end end unless lights_frac_radiant.zero? - definition.setFractionRadiant(lights_frac_radiant) + if lights_type == 'NECB_Default' + definition.setFractionRadiant(lights_frac_radiant) + elsif lights_type == 'LED' + definition.setFractionRadiant(lights_frac_radiant_led_lighting) + end end unless lights_frac_visible.zero? - definition.setFractionVisible(lights_frac_visible) + if lights_type == 'NECB_Default' + definition.setFractionVisible(lights_frac_visible) + elsif lights_type == 'LED' + definition.setFractionVisible(lights_frac_visible_led_lighting) + end end # unless lights_frac_replaceable.zero? # definition.setFractionReplaceable(lights_frac_replaceable) # end end @@ -68,10 +117,9 @@ # Create the lighting instance and hook it up to the space type additional_lights = OpenStudio::Model::Lights.new(additional_lights_def) additional_lights.setName("#{space_type.name} Additional Lights") additional_lights.setSpaceType(space_type) end - end end def set_lighting_per_area(space_type, definition, lighting_per_area)