_construction = opaque_construction_by_identifier(_construction) # determine whether the input _geo_or_area is geometry or floats try: areas = [float(num) for num in _geo_or_area] except AttributeError: # assume that the input is a list of geometry geo = [f for geo in _geo_or_area for f in to_face3d(geo)] conversion = conversion_to_meters()**2 areas = [0 for room in rooms] for i, room in enumerate(rooms): for face in geo: if room.geometry.is_point_inside(face.center): areas[i] += face.area * conversion # create the internal mass objects and assign them to the rooms for i, room in enumerate(rooms): area = longest_list(areas, i) if area != 0: if len(_name_) == 0: # make a default Room name display_name = 'Internal Mass {}'.format( document_counter('mass_count')) else: display_name = '{}_{}'.format(longest_list(_name_, i), i + 1) \ if len(_name_) != len(_rooms) else longest_list(_name_, i) name = clean_ep_string(display_name) mass = InternalMass(name, _construction, area) mass.display_name = display_name room.properties.energy.add_internal_mass(mass) print('Internal mass with area {} m2 has been added to room ' '"{}"'.format(round(area, 3), room.display_name))
'has failed to import.\n{}'.format(e)) elif len(conditioned_) != 0: raise ValueError( 'conditioned_ has been specified but dragonfly-energy ' 'has failed to import.\n{}'.format(e)) if all_required_inputs(ghenv.Component): room2d = [] # list of room2ds that will be returned face3ds = [face for geo in _geo for face in to_face3d(geo)] # convert to lb geo for i, geo in enumerate(face3ds): # get the name for the Room2D if len(_name_) == 0: # make a default Room2D name display_name = 'Room_{}'.format(document_counter('room_count')) else: display_name = '{}_{}'.format(longest_list(_name_, i), i + 1) \ if len(_name_) != len(face3ds) else longest_list(_name_, i) name = clean_and_id_string(display_name) # create the Room2D room = Room2D(name, geo, longest_list(_flr_to_ceiling, i), tolerance=tolerance) room.display_name = display_name # assign the program if len(_program_) != 0: program = longest_list(_program_, i) if isinstance(program, str): program = program_type_by_identifier(program)
rh_lines = [] hr_lines = [] enth_wb_lines = [] mesh = [] legend = [] points = [] data_colls = [] psych_chart = [] # loop through the input temperatures and humidity and plot psych charts for j, (temperature, rel_humid) in enumerate(zip(_temperature, _rel_humidity)): # process the pressure input pressure = 101325 if len(_pressure_) != 0: pr = longest_list(_pressure_, j) try: pressure = float(pr) except Exception: # assume that it's a data collection assert pr.header.unit == 'Pa', '_pressure_ input must be in Pa.' pressure = pr.average # sense if the input temperature is in Farenheit use_ip = False if isinstance(temperature, BaseCollection): if temperature.header.unit != 'C': # convert to C and set chart to use_ip temperature = temperature.to_si() use_ip = True # set default values for the chart dimensions _scale_ = 1.0 if _scale_ is None else _scale_
try: from ladybug_rhino.grasshopper import all_required_inputs, longest_list from ladybug_rhino.config import conversion_to_meters except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): conversion = conversion_to_meters() rooms = [room.duplicate() for room in _rooms] # duplicate the initial objects # assign the person_count_ if len(person_count_) != 0: for i, room in enumerate(rooms): room.properties.energy.abolute_people( longest_list(person_count_, i), conversion) # assign the lighting_watts_ if len(lighting_watts_) != 0: for i, room in enumerate(rooms): room.properties.energy.abolute_lighting( longest_list(lighting_watts_, i), conversion) # assign the electric_watts_ if len(electric_watts_) != 0: for i, room in enumerate(rooms): room.properties.energy.abolute_electric_equipment( longest_list(electric_watts_, i), conversion) # assign the gas_watts_ if len(gas_watts_) != 0:
'has failed to import.\n{}'.format(e)) try: # import the honeybee-radiance extension from honeybee_radiance.lib.modifiers import modifier_by_identifier except ImportError as e: if len(rad_mod_) != 0: raise ValueError('rad_mod_ has been specified but honeybee-radiance ' 'has failed to import.\n{}'.format(e)) if all_required_inputs(ghenv.Component): shades = [] # list of shades that will be returned for j, geo in enumerate(_geo): if len(_name_) == 0: # make a default Shade name name = display_name = clean_and_id_string('Shade') else: display_name = '{}_{}'.format(longest_list(_name_, j), j + 1) \ if len(_name_) != len(_geo) else longest_list(_name_, j) name = clean_and_id_string(display_name) is_detached = not longest_list(attached_, j) if len(attached_) != 0 else True lb_faces = to_face3d(geo) for i, lb_face in enumerate(lb_faces): shd_name = '{}_{}'.format(name, i) if len(lb_faces) > 1 else name hb_shd = Shade(shd_name, lb_face, is_detached) hb_shd.display_name = display_name # try to assign the energyplus construction if len(ep_constr_) != 0: ep_constr = longest_list(ep_constr_, j) if isinstance(ep_constr, str):
ghenv.Component.AdditionalHelpFromDocStrings = "1" try: from honeybee.room import Room except ImportError as e: raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e)) try: from honeybee_energy.lib.programtypes import program_type_by_identifier, \ building_program_type_by_identifier except ImportError as e: raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e)) try: from ladybug_rhino.grasshopper import all_required_inputs, longest_list except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): # duplicate the initial objects rooms = [obj.duplicate() for obj in _rooms if isinstance(obj, Room)] # apply the program to the rooms for i, room in enumerate(rooms): prog = longest_list(_program, i) if isinstance(prog, str): # get the program object if it is a string try: prog = building_program_type_by_identifier(prog) except ValueError: prog = program_type_by_identifier(prog) room.properties.energy.program_type = prog
try: from ladybug_rhino.grasshopper import all_required_inputs, longest_list from ladybug_rhino.config import conversion_to_meters except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): conversion = conversion_to_meters() rooms = [room.duplicate() for room in _rooms] # duplicate the initial objects # assign the person_count_ if len(person_count_) != 0: for i, room in enumerate(rooms): room.properties.energy.abolute_people( longest_list(person_count_, i), conversion) # assign the lighting_watts_ if len(lighting_watts_) != 0: for i, room in enumerate(rooms): room.properties.energy.abolute_lighting( longest_list(lighting_watts_, i), conversion) # assign the electric_watts_ if len(electric_watts_) != 0: for i, room in enumerate(rooms): room.properties.energy.abolute_electric_equipment( longest_list(electric_watts_, i), conversion) # assign the gas_watts_ if len(gas_watts_) != 0:
'has failed to import.\n{}'.format(e)) elif len(conditioned_) != 0: raise ValueError( 'conditioned_ has been specified but dragonfly-energy ' 'has failed to import.\n{}'.format(e)) if all_required_inputs(ghenv.Component) and _run: perim_offset_ = 0 if perim_offset_ is None else perim_offset_ buildings = [] # list of buildings that will be returned for i, geo in enumerate(_footprint_geo): # get the name for the Building if len(_name_) == 0: # make a default Building name display_name = 'Building_{}'.format(document_counter('bldg_count')) name = clean_and_id_string(display_name) else: display_name = '{}_{}'.format(longest_list(_name_, i), i + 1) \ if len(_name_) != len(_footprint_geo) else longest_list(_name_, i) name = clean_string(display_name) # create the Building building = Building.from_footprint( name, footprint=to_face3d(geo), floor_to_floor_heights=_floor_to_floor, perimeter_offset=perim_offset_, tolerance=tolerance) building.display_name = display_name # assign the program if len(_program_) != 0: program = longest_list(_program_, i)
if len(ep_constr_) != 0: raise ValueError('ep_constr_ has been specified but honeybee-energy ' 'has failed to import.\n{}'.format(e)) elif len(ep_trans_sch_) != 0: raise ValueError('ep_trans_sch_ has been specified but honeybee-energy ' 'has failed to import.\n{}'.format(e)) if all_required_inputs(ghenv.Component): context = [] # list of context shades that will be returned for i, geo in enumerate(_geo): # get the name for the ContextShade if len(_name_) == 0: # make a default name display_name = 'Context_{}'.format(document_counter('context_count')) else: display_name = '{}_{}'.format(longest_list(_name_, i), i + 1) \ if len(_name_) != len(_geo) else longest_list(_name_, i) name = clean_and_id_string(display_name) # create the ContextShade object df_shd = ContextShade(name, to_face3d(geo)) df_shd.display_name = display_name # try to assign the energyplus construction if len(ep_constr_) != 0: ep_constr = longest_list(ep_constr_, i) if isinstance(ep_constr, str): ep_constr = shade_construction_by_identifier(ep_constr) df_shd.properties.energy.construction = ep_constr # try to assign the energyplus transmittance schedule
'has failed to import.\n{}'.format(e)) try: # import the honeybee-radiance extension from honeybee_radiance.lib.modifiers import modifier_by_identifier except ImportError as e: if len(rad_mod_) != 0: raise ValueError('rad_mod_ has been specified but honeybee-radiance ' 'has failed to import.\n{}'.format(e)) if all_required_inputs(ghenv.Component): faces = [] # list of faces that will be returned for j, geo in enumerate(_geo): if len(_name_) == 0: # make a default Face name name = display_name = clean_and_id_string('Face') else: display_name = '{}_{}'.format(longest_list(_name_, j), j + 1) \ if len(_name_) != len(_geo) else longest_list(_name_, j) name = clean_and_id_string(display_name) typ = longest_list(_type_, j) if len(_type_) != 0 else None bc = longest_list(_bc_, j) if len(_bc_) != 0 else None if typ is not None and typ not in face_types: typ = face_types.by_name(typ) if bc is not None and bc not in boundary_conditions: bc = boundary_conditions.by_name(bc) lb_faces = to_face3d(geo) for i, lb_face in enumerate(lb_faces): face_name = '{}_{}'.format(name, i) if len(lb_faces) > 1 else name hb_face = Face(face_name, lb_face, typ, bc) hb_face.display_name = display_name
rooms: The input Rooms with their multipliers edited. """ ghenv.Component.Name = "HB Set Multiplier" ghenv.Component.NickName = 'Multiplier' ghenv.Component.Message = '1.2.0' ghenv.Component.Category = 'Honeybee' ghenv.Component.SubCategory = '0 :: Create' ghenv.Component.AdditionalHelpFromDocStrings = '0' try: # import the honeybee-energy extension from honeybee.room import Room except ImportError as e: raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e)) try: # import the ladybug_rhino dependencies from ladybug_rhino.grasshopper import all_required_inputs, longest_list except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): rooms = [] for i, room in enumerate(_rooms): assert isinstance(room, Room), \ 'Expected honeybee room. Got {}.'.format(type(room)) room_dup = room.duplicate() room_dup.multiplier = longest_list(_multiplier, i) rooms.append(room_dup)
wire_objs = [] for wire in _wires: if isinstance(wire, str): wire_objs.append(wire_by_identifier(wire)) else: wire_objs.append(wire) # convert rhino geometry to ladybug geometry lines = [] for geo in _geo: try: lines.append(to_polyline2d(geo)) except AttributeError: lines.append(to_linesegment2d(geo)) connector = [] # list of connectors that will be returned for i, geo in enumerate(lines): # get the name for the ElectricalConnector if len(_name_) == 0: # make a default ElectricalConnector name display_name = 'ElectricalConnector_{}'.format( document_counter('e_connector_count')) else: display_name = '{}_{}'.format(longest_list(_name_, i), i + 1) \ if len(_name_) != len(lines) else longest_list(_name_, i) name = clean_and_id_ep_string(display_name) # create the ElectricalConnector conn = ElectricalConnector(name, geo, wire_objs) conn.display_name = display_name connector.append(conn)
try: from ladybug_rhino.grasshopper import all_required_inputs, give_warning, \ longest_list except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): # loop through the rooms and assign the objects op_count = 0 rooms = [] for i, room_init in enumerate(_rooms): room = room_init.duplicate() # duplicate to avoid editing the input # assign the ventilation control for the windows room.properties.energy.window_vent_control = longest_list(_vent_cntrl, i) # create the base ventilation opening f_area = 0.5 if len(_fract_area_oper_) == 0 else longest_list(_fract_area_oper_, i) f_height = 1.0 if len(_fract_height_oper_) == 0 else longest_list(_fract_height_oper_, i) discharge = 0.45 if len(_discharge_coeff_) == 0 else longest_list(_discharge_coeff_, i) vent_open = VentilationOpening(f_area, f_height, discharge) # assign the cross ventilation cross_vent = longest_list(_wind_cross_vent_, i) if \ len(_wind_cross_vent_) != 0 else None if cross_vent is None: # analyze normals of room's apertures to test if cross vent is possible orient_angles = [] for face in room.faces: for ap in face.apertures:
except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): # duplicate the initial objects rooms = [room.duplicate() for room in _rooms] # set default values and check the inputs use_category_ = ['Process'] if len(use_category_) == 0 else use_category_ radiant_fract_ = [0.0] if len(radiant_fract_) == 0 else radiant_fract_ latent_fract_ = [0.0] if len(latent_fract_) == 0 else latent_fract_ lost_fract_ = [0.0] if len(lost_fract_) == 0 else lost_fract_ for i, sched in enumerate(_schedule): if isinstance(sched, str): _schedule[i] = schedule_by_identifier(sched) # loop through the rooms and assign process loads for i, room in enumerate(rooms): load_watts = longest_list(_watts, i) if load_watts != 0: name = clean_and_id_ep_string('Process') if len(_name_) == 0 else \ clean_ep_string(longest_list(_name_, i)) process = Process('{}..{}'.format(name, room.identifier), load_watts, longest_list(_schedule, i), longest_list(_fuel_type, i), longest_list(use_category_, i), longest_list(radiant_fract_, i), longest_list(latent_fract_, i), longest_list(lost_fract_, i)) room.properties.energy.add_process_load(process)
mod_obj.append(duplicate_and_id_program(obj)) elif isinstance(obj, str): try: program = building_program_type_by_identifier(obj) except ValueError: program = program_type_by_identifier(obj) mod_obj.append(duplicate_and_id_program(program)) else: raise TypeError('Expected Honeybee Room or ProgramType. ' 'Got {}.'.format(type(obj))) # assign the people_per_floor_ if len(people_per_floor_) != 0: for i, obj in enumerate(mod_obj): people = dup_load(obj, 'people', People) people.people_per_area = longest_list(people_per_floor_, i) assign_load(obj, people, 'people') # assign the lighting_per_floor_ if len(lighting_per_floor_) != 0: for i, obj in enumerate(mod_obj): lighting = dup_load(obj, 'lighting', Lighting) lighting.watts_per_area = longest_list(lighting_per_floor_, i) assign_load(obj, lighting, 'lighting') # assign the electric_per_floor_ if len(electric_per_floor_) != 0: for i, obj in enumerate(mod_obj): equip = dup_load(obj, 'electric_equipment', ElectricEquipment) equip.watts_per_area = longest_list(electric_per_floor_, i) assign_load(obj, equip, 'electric_equipment')
(and child objects') identifier and display_name. This will also be added to any Surface boundary conditions of Faces, Apertures, or Doors. It is recommended that this prefix be short to avoid maxing out the 100 allowable characters for honeybee identifiers. This can also be a list of prefixes that correspond to the input _hb_objs Returns: report: ... hb_objs: The input Honeybee objects with a prefix added to their display names and identifiers. """ ghenv.Component.Name = "HB Add Prefix" ghenv.Component.NickName = 'Prefix' ghenv.Component.Message = '1.2.0' ghenv.Component.Category = 'Honeybee' ghenv.Component.SubCategory = '0 :: Create' ghenv.Component.AdditionalHelpFromDocStrings = '0' try: # import the ladybug_rhino dependencies from ladybug_rhino.grasshopper import all_required_inputs, longest_list except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): hb_objs = [] for i, obj in enumerate(_hb_objs): obj_dup = obj.duplicate() prefix = longest_list(_prefix, i) obj_dup.add_prefix(prefix) hb_objs.append(obj_dup)
if len(_sensor_points_) != 0: assert len(_sensor_points_) == len(_rooms), 'Number of sensor points ({}) ' \ 'must align exactly with the number of rooms ({}).'.format( len(_sensor_points_), len(_rooms)) _ill_setpoint_ = [300] if len(_ill_setpoint_) == 0 else _ill_setpoint_ _control_fract_ = [1] if len(_control_fract_) == 0 else _control_fract_ _min_power_in_ = [0.3] if len(_min_power_in_) == 0 else _min_power_in_ _min_light_out_ = [0.2] if len(_min_light_out_) == 0 else _min_light_out_ off_at_min_ = [False] if len(off_at_min_) == 0 else off_at_min_ # loop through the rooms and assign daylight sensors unassigned_rooms = [] if len(_sensor_points_) == 0: for i, room in enumerate(rooms): dl_control = room.properties.energy.add_daylight_control_to_center( dist_from_floor, longest_list(_ill_setpoint_, i), longest_list(_control_fract_, i), longest_list(_min_power_in_, i), longest_list(_min_light_out_, i), longest_list(off_at_min_, i)) if dl_control is None: unassigned_rooms.append(room.display_name) else: for i, room in enumerate(rooms): sensor_pt = to_point3d(_sensor_points_[i]) if room.geometry.is_point_inside(sensor_pt): dl_control = DaylightingControl( sensor_pt, longest_list(_ill_setpoint_, i), longest_list(_control_fract_, i), longest_list(_min_power_in_, i), longest_list(_min_light_out_, i), longest_list(off_at_min_, i))
try: from itertools import izip as zip # python 2 except ImportError: pass # some future time when GHPython upgrades to python 3 if all_required_inputs(ghenv.Component): # build the arithmetic statement operator = '+' if _operator_ is None else _operator_ statement = 'data_1 {} data_2'.format(operator) # perform the arithmetic operation data = [] for i, data_1 in enumerate(_data_1): data_2 = longest_list(_data_2, i) data_1 = float(data_1) if isinstance(data_1, str) else data_1 data_2 = float(data_2) if isinstance(data_2, str) else data_2 result = eval(statement, {'data_1': data_1, 'data_2': data_2}) # try to replace the data collection type try: result = result.duplicate() if type_: result.header.metadata['type'] = type_ elif 'type' in result.header.metadata: # infer data type from units d_unit = result.header.unit for key in ladybug.datatype.UNITS: if d_unit in ladybug.datatype.UNITS[key]: base_type = ladybug.datatype.TYPESDICT[key]() result.header.metadata['type'] = str(base_type)
if isinstance(obj, Room): mod_obj.append(obj.duplicate()) elif isinstance(obj, ProgramType): mod_obj.append(duplicate_and_id_program(obj)) elif isinstance(obj, str): program = program_type_by_identifier(obj) mod_obj.append(duplicate_and_id_program(program)) else: raise TypeError('Expected Honeybee Room or ProgramType. ' 'Got {}.'.format(type(obj))) # assign the cooling_setpt_ if len(cooling_setpt_) != 0: for i, obj in enumerate(mod_obj): setpoint = dup_setpoint(obj) setpoint.cooling_setpoint = longest_list(cooling_setpt_, i) assign_setpoint(obj, setpoint) # assign the heating_setpt_ if len(heating_setpt_) != 0: for i, obj in enumerate(mod_obj): setpoint = dup_setpoint(obj) setpoint.heating_setpoint = longest_list(heating_setpt_, i) assign_setpoint(obj, setpoint) # assign the humid_setpt_ if len(humid_setpt_) != 0: for i, obj in enumerate(mod_obj): setpoint = dup_setpoint(obj) setpoint.humidifying_setpoint = longest_list(humid_setpt_, i) assign_setpoint(obj, setpoint)
'has failed to import.\n{}'.format(e)) try: # import the honeybee-radiance extension from honeybee_radiance.lib.modifiers import modifier_by_identifier except ImportError as e: if len(rad_mod_) != 0: raise ValueError('rad_mod_ has been specified but honeybee-radiance ' 'has failed to import.\n{}'.format(e)) if all_required_inputs(ghenv.Component): doors = [] # list of doors that will be returned for j, geo in enumerate(_geo): if len(_name_) == 0: # make a default Door name name = display_name = clean_and_id_string('Door') else: display_name = '{}_{}'.format(longest_list(_name_, j), j + 1) \ if len(_name_) != len(_geo) else longest_list(_name_, j) name = clean_and_id_string(display_name) glass = longest_list(glass_, j) if len(glass_) != 0 else False lb_faces = to_face3d(geo) for i, lb_face in enumerate(lb_faces): dr_name = '{}_{}'.format(name, i) if len(lb_faces) > 1 else name hb_dr = Door(dr_name, lb_face, is_glass=glass) hb_dr.display_name = display_name # try to assign the energyplus construction if len(ep_constr_) != 0: ep_constr = longest_list(ep_constr_, j) if isinstance(ep_constr, str): ep_constr = opaque_construction_by_identifier(ep_constr) if not \
mod_obj.append(obj.duplicate()) elif isinstance(obj, ProgramType): mod_obj.append(duplicate_and_id_program(obj)) elif isinstance(obj, str): program = program_type_by_identifier(obj) mod_obj.append(duplicate_and_id_program(program)) else: raise TypeError('Expected Honeybee Room or ProgramType. ' 'Got {}.'.format(type(obj))) # assign the occupancy schedule if len(occupancy_sch_) != 0: for i, obj in enumerate(mod_obj): people = dup_load(obj, 'people', 'occupancy_sch_') people.occupancy_schedule = schedule_object( longest_list(occupancy_sch_, i)) assign_load(obj, people, 'people') # assign the activity schedule if len(activity_sch_) != 0: for i, obj in enumerate(mod_obj): people = dup_load(obj, 'people', 'activity_sch_') people.activity_schedule = schedule_object( longest_list(activity_sch_, i)) assign_load(obj, people, 'people') # assign the lighting schedule if len(lighting_sch_) != 0: for i, obj in enumerate(mod_obj): lighting = dup_load(obj, 'lighting', 'lighting_sch_') lighting.schedule = schedule_object(longest_list(lighting_sch_, i))
try: # import ladybug-rhino from ladybug_rhino.togeometry import to_polygon2d from ladybug_rhino.grasshopper import all_required_inputs, longest_list, \ document_counter except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): transformer = [] # list of transformers that will be returned polygons = [to_polygon2d(geo) for geo in _geo] # convert to lb geo for i, geo in enumerate(polygons): # get the name for the Transformer if len(_name_) == 0: # make a default Transformer name display_name = 'Transformer_{}'.format( document_counter('transformer_count')) else: display_name = '{}_{}'.format(longest_list(_name_, i), i + 1) \ if len(_name_) != len(polygons) else longest_list(_name_, i) name = clean_and_id_ep_string(display_name) # get the properties for the transformer props = longest_list(_properties, i) if isinstance(props, str): props = transformer_prop_by_identifier(props) # create the Transformer trans = Transformer(name, geo, props) trans.display_name = display_name transformer.append(trans)