def test_schedule_lib(): """Test that the honeybee-energy lib has been extended with new schedule data.""" assert len(sched_lib.SCHEDULES) > 8 # should now have many more schedules sched_from_lib = sched_lib.schedule_by_identifier(sched_lib.SCHEDULES[0]) assert isinstance(sched_from_lib, ScheduleRuleset) sched_from_lib = sched_lib.schedule_by_identifier(sched_lib.SCHEDULES[8]) assert isinstance(sched_from_lib, ScheduleRuleset)
def opaque_construction_by_identifier(construction_identifier): """Get an opaque construction from the library given the construction identifier. Args: construction_identifier: A text string for the identifier of the construction. """ try: return _opaque_constructions[construction_identifier] except KeyError: try: # search the extension data constr_dict = _opaque_constr_standards_dict[ construction_identifier] if constr_dict['type'] == 'OpaqueConstructionAbridged': mats = {} mat_key = 'layers' if 'layers' in constr_dict else 'materials' for mat in constr_dict[mat_key]: mats[mat] = _m.opaque_material_by_identifier(mat) return OpaqueConstruction.from_dict_abridged(constr_dict, mats) else: # AirBoundaryConstruction try: sch_id = constr_dict['air_mixing_schedule'] schs = {sch_id: _s.schedule_by_identifier(sch_id)} except KeyError: # no air mixing key provided schs = {} return AirBoundaryConstruction.from_dict_abridged( constr_dict, schs) except KeyError: # construction is nowhere to be found; raise an error raise ValueError( '"{}" was not found in the opaque energy construction library.' .format(construction_identifier))
def window_construction_by_identifier(construction_identifier): """Get an window construction from the library given the construction identifier. Args: construction_identifier: A text string for the identifier of the construction. """ try: return _window_constructions[construction_identifier] except KeyError: try: # search the extension data constr_dict = _window_constr_standards_dict[ construction_identifier] if constr_dict['type'] == 'WindowConstructionAbridged': mats = {} for mat in constr_dict['layers']: mats[mat] = _m.window_material_by_identifier(mat) return WindowConstruction.from_dict_abridged(constr_dict, mats) else: # WindowConstructionShade mats = {} for mat in constr_dict['window_construction']['layers']: mats[mat] = _m.window_material_by_identifier(mat) shd_mat = constr_dict['shade_material'] mats[shd_mat] = _m.window_material_by_identifier(shd_mat) try: sch_id = constr_dict['schedule'] schs = {sch_id: _s.schedule_by_identifier(sch_id)} except KeyError: # no schedule key provided schs = {} return WindowConstructionShade.from_dict_abridged( constr_dict, mats, schs) except KeyError: # construction is nowhere to be found; raise an error raise ValueError( '"{}" was not found in the window energy construction library.' .format(construction_identifier))
def schedule_by_id(schedule_id, abridged, output_file): """Get a schedule definition from the standards lib with its identifier. \n Args: schedule_id: The identifier of a schedule in the library. """ try: output_file.write(json.dumps(schedule_by_identifier( schedule_id).to_dict(abridged=abridged))) except Exception as e: _logger.exception('Retrieval from schedule library failed.\n{}'.format(e)) sys.exit(1) else: sys.exit(0)
def schedules_by_id(schedule_ids, abridged, output_file): """Get several schedule definitions from the standards lib at once. \n Args: schedule_ids: A list of schedule identifiers to be retrieved from the library. """ try: schs = [] for sch_id in schedule_ids: schs.append(schedule_by_identifier(sch_id)) output_file.write(json.dumps([sch.to_dict(abridged=abridged) for sch in schs])) except Exception as e: _logger.exception('Retrieval from schedule library failed.\n{}'.format(e)) sys.exit(1) else: sys.exit(0)
def hb_schedule_to_data(_schedule_name): try: _schedule = schedule_by_identifier(_schedule_name) except: return None week_start_day = 'Sunday' start_date, end_date, timestep = Date(1, 1), Date(12, 31), 1 holidays = None data = _schedule.data_collection(timestep, start_date, end_date, week_start_day, holidays, leap_year=False) return data
def from_standards_dict(cls, data): """Create a ProgramType from an OpenStudio standards gem dictionary. Args: data: An OpenStudio standards dictionary of a space type in the format below. .. code-block:: python { "template": "90.1-2013", "building_type": "Office", "space_type": "MediumOffice - OpenOffice", "lighting_standard": "ASHRAE 90.1-2013", "lighting_per_area": 0.98, "lighting_per_person": None, "additional_lighting_per_area": None, "lighting_fraction_to_return_air": 0.0, "lighting_fraction_radiant": 0.7, "lighting_fraction_visible": 0.2, "lighting_schedule": "OfficeMedium BLDG_LIGHT_SCH_2013", "ventilation_standard": "ASHRAE 62.1-2007", "ventilation_primary_space_type": "Office Buildings", "ventilation_secondary_space_type": "Office space", "ventilation_per_area": 0.06, "ventilation_per_person": 5.0, "ventilation_air_changes": None, "minimum_total_air_changes": None, "occupancy_per_area": 5.25, "occupancy_schedule": "OfficeMedium BLDG_OCC_SCH", "occupancy_activity_schedule": "OfficeMedium ACTIVITY_SCH", "infiltration_per_exterior_area": 0.0446, "infiltration_schedule": "OfficeMedium INFIL_SCH_PNNL", "gas_equipment_per_area": None, "gas_equipment_fraction_latent": None, "gas_equipment_fraction_radiant": None, "gas_equipment_fraction_lost": None, "gas_equipment_schedule": None, "electric_equipment_per_area": 0.96, "electric_equipment_fraction_latent": 0.0, "electric_equipment_fraction_radiant": 0.5, "electric_equipment_fraction_lost": 0.0, "electric_equipment_schedule": "OfficeMedium BLDG_EQUIP_SCH_2013", "heating_setpoint_schedule": "OfficeMedium HTGSETP_SCH_YES_OPTIMUM", "cooling_setpoint_schedule": "OfficeMedium CLGSETP_SCH_YES_OPTIMUM" } """ pr_type_identifier = data['space_type'] people = None lighting = None electric_equipment = None gas_equipment = None hot_water = None infiltration = None ventilation = None setpoint = None if 'occupancy_schedule' in data and data['occupancy_schedule'] is not None and \ 'occupancy_per_area' in data and data['occupancy_per_area'] != 0: occ_sched = sch_lib.schedule_by_identifier(data['occupancy_schedule']) act_sched = sch_lib.schedule_by_identifier( data['occupancy_activity_schedule']) occ_density = data['occupancy_per_area'] / 92.903 people = People('{}_People'.format(pr_type_identifier), occ_density, occ_sched, act_sched) if 'lighting_schedule' in data and data['lighting_schedule'] is not None: light_sched = sch_lib.schedule_by_identifier(data['lighting_schedule']) try: lpd = data['lighting_per_area'] * 10.7639 except (TypeError, KeyError): lpd = 0 # there's a schedule but no actual load object try: raf = data['lighting_fraction_to_return_air'] except KeyError: raf = 0 try: lfr = data['lighting_fraction_radiant'] except KeyError: lfr = 0.32 try: lfv = data['lighting_fraction_visible'] except KeyError: lfv = 0.25 lighting = Lighting('{}_Lighting'.format(pr_type_identifier), lpd, light_sched, raf, lfr, lfv) lighting.baseline_watts_per_area = lpd if 'electric_equipment_schedule' in data and \ data['electric_equipment_schedule'] is not None: eequip_sched = sch_lib.schedule_by_identifier( data['electric_equipment_schedule']) try: eepd = data['electric_equipment_per_area'] * 10.7639 except KeyError: eepd = 0 # there's a schedule but no actual load object electric_equipment = ElectricEquipment( '{}_Electric'.format(pr_type_identifier), eepd, eequip_sched, data['electric_equipment_fraction_radiant'], data['electric_equipment_fraction_latent'], data['electric_equipment_fraction_lost']) if 'gas_equipment_schedule' in data and \ data['gas_equipment_schedule'] is not None: gequip_sched = sch_lib.schedule_by_identifier( data['gas_equipment_schedule']) try: gepd = data['gas_equipment_per_area'] * 3.15459 except (TypeError, KeyError): gepd = 0 # there's a schedule but no actual load object gas_equipment = GasEquipment('{}_Gas'.format(pr_type_identifier), gepd, gequip_sched, data['gas_equipment_fraction_radiant'], data['gas_equipment_fraction_latent'], data['gas_equipment_fraction_lost']) if 'service_water_heating_schedule' in data and \ data['service_water_heating_schedule'] is not None: shw_sch = sch_lib.schedule_by_identifier( data['service_water_heating_schedule']) try: shw_load = data[ 'service_water_heating_peak_flow_per_area'] * 40.7458 except (TypeError, KeyError): shw_load = 0 # there's a schedule but no actual load object try: shw_temp = round( (data['service_water_heating_target_temperature'] - 32.) * 5. / 9.) except (TypeError, KeyError): shw_temp = 60 try: fs = data['service_water_heating_fraction_sensible'] except (TypeError, KeyError): fs = 0.2 try: fl = data['service_water_heating_fraction_latent'] except (TypeError, KeyError): fl = 0.05 hot_water = ServiceHotWater('{}_SHW'.format(pr_type_identifier), shw_load, shw_sch, shw_temp, fs, fl) if 'infiltration_schedule' in data and \ data['infiltration_schedule'] is not None: inf_sched = sch_lib.schedule_by_identifier( data['infiltration_schedule']) try: inf = data['infiltration_per_exterior_area'] * 0.00508 except KeyError: # might be using infiltration_per_exterior_wall_area try: inf = data['infiltration_per_exterior_wall_area'] * 0.00508 except KeyError: inf = 0 # there's a schedule but no actual load object infiltration = Infiltration( '{}_Infiltration'.format(pr_type_identifier), inf, inf_sched) if 'ventilation_standard' in data and \ data['ventilation_standard'] is not None: person = data['ventilation_per_person'] * 0.000471947 if \ 'ventilation_per_person' in data and \ data['ventilation_per_person'] is not None else 0 area = data['ventilation_per_area'] * 0.00508 if \ 'ventilation_per_area' in data and \ data['ventilation_per_area'] is not None else 0 ach = data['ventilation_air_changes'] if \ 'ventilation_air_changes' in data and \ data['ventilation_air_changes'] is not None else 0 ventilation = Ventilation('{}_Ventilation'.format(pr_type_identifier), person, area, 0, ach) if 'heating_setpoint_schedule' in data and \ data['heating_setpoint_schedule'] is not None: heat_sched = sch_lib.schedule_by_identifier( data['heating_setpoint_schedule']) cool_sched = sch_lib.schedule_by_identifier( data['cooling_setpoint_schedule']) setpoint = Setpoint('{}_Setpoint'.format(pr_type_identifier), heat_sched, cool_sched) return cls(data['space_type'], people, lighting, electric_equipment, gas_equipment, hot_water, infiltration, ventilation, setpoint)
_sys_name = hvac_dict[_system_type] except KeyError: _sys_name = _system_type hvac_class = EQUIPMENT_TYPES_DICT[_sys_name] except KeyError: raise ValueError('System Type "{}" is not recognized as a DOAS HVAC ' 'system.'.format(_system_type)) vintage = vintages[_vintage_] # get the vintage of the HVAC name = clean_and_id_ep_string( 'DOAS HVAC') if _name_ is None else clean_ep_string(_name_) # create the HVAC hvac = hvac_class(name, vintage, _sys_name, sensible_hr_, latent_hr_, dcv_) if doas_avail_sch_ is not None: if isinstance(doas_avail_sch_, str): doas_avail_sch_ = schedule_by_identifier(doas_avail_sch_) hvac.doas_availability_schedule = doas_avail_sch_ if _name_ is not None: hvac.display_name = _name_ # apply the HVAC system to the rooms vent_scheds = set() hvac_count = 0 for room in rooms: if room.properties.energy.is_conditioned: room.properties.energy.hvac = hvac vent_obj = room.properties.energy.ventilation if vent_obj is not None: vent_scheds.add(vent_obj.schedule) hvac_count += 1
from honeybee_energy.lib.schedules import schedule_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 except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): # make a default Setpoint name if none is provided name = clean_and_id_ep_string('Setpoint') if _name_ is None else \ clean_ep_string(_name_) # get the schedules if isinstance(_heating_sch, str): _heating_sch = schedule_by_identifier(_heating_sch) if isinstance(_cooling_sch, str): _cooling_sch = schedule_by_identifier(_cooling_sch) # create the Setpoint object setpoint = Setpoint(name, _heating_sch, _cooling_sch) if _name_ is not None: setpoint.display_name = _name_ # assign the humidification and dehumidification setpoints if requested if humid_setpt_ is not None: setpoint.humidifying_setpoint = humid_setpt_ if dehumid_setpt_ is not None: setpoint.dehumidifying_setpoint = dehumid_setpt_
from honeybee.typing import clean_and_id_ep_string, clean_ep_string except ImportError as e: raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e)) try: from honeybee_energy.load.infiltration import Infiltration from honeybee_energy.lib.schedules import schedule_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 except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): # make a default Infiltration name if none is provided name = clean_and_id_ep_string('Infiltration') if _name_ is None else \ clean_ep_string(_name_) # get the schedule _schedule_ = _schedule_ if _schedule_ is not None else 'Always On' if isinstance(_schedule_, str): _schedule_ = schedule_by_identifier(_schedule_) # create the Infiltration object infil = Infiltration(name, _flow_per_ext_area, _schedule_) if _name_ is not None: infil.display_name = _name_
if len(_min_max_) != 0: assert len(_min_max_), 'Expected two values for _min_max_.' min_t = _min_max_[0] max_t = _min_max_[1] else: min_t = 100 max_t = 2000 # process the schedule and sun-up hours if _occ_sch_ is None: schedule = generate_default_schedule() elif isinstance(_occ_sch_, BaseCollection): schedule = _occ_sch_.values elif isinstance(_occ_sch_, str): if schedule_by_identifier is not None: schedule = schedule_by_identifier(_occ_sch_).values() else: raise ValueError('honeybee-energy must be installed to reference ' 'occupancy schedules by identifier.') else: # assume that it is a honeybee schedule object schedule = _occ_sch_.values() total_occupied_hours = sum(schedule) occ_pattern = parse_sun_up_hours(_results, schedule) # compute the annual metrics DA, UDI = [], [] for ill_file in _results: da, udi = annual_metrics(ill_file, occ_pattern, total_occupied_hours, _threshold_, min_t, max_t) DA.append(da) UDI.append(udi)
def add_schedule(scheds, p_type_dict, load_id, sch_id): try: sch_id = p_type_dict[load_id][sch_id] scheds[sch_id] = _s.schedule_by_identifier(sch_id) except KeyError: pass # key is not included
def convert_to_hb_json(source_dir=None, dest_dir=None): """Convert OpenStudio standards JSON files into Honeybee JSON files. Args: source_dir: Directory to the cleaned OpenStudio Standards JSONs. Default will be the data folder in this package. dest_dir: Optional path to a destination directory. Default will be the data folder in this package. """ # set default directories if source_dir is None: master_dir = local_data_dir() source_dir = os.path.join(master_dir, '_standards_data') if dest_dir is None: master_dir = local_data_dir() dest_dir = os.path.join(master_dir, 'data') # get all of the destination folders constr_dir = os.path.join(dest_dir, 'constructions') constrset_dir = os.path.join(dest_dir, 'constructionsets') sched_dir = os.path.join(dest_dir, 'schedules') ptype_dir = os.path.join(dest_dir, 'programtypes') ptype_reg_dir = os.path.join(dest_dir, 'programtypes_registry') # translate the materials and constructions to honeybee_json extra_folder = os.path.join( os.path.split(os.path.dirname(__file__))[0], '_extra') honeybee_construction_json( source_dir, constr_dir, mat_lib.opaque_material_by_identifier, 'opaque_material.json', [os.path.join(extra_folder, 'ground_materials.json')]) honeybee_construction_json(source_dir, constr_dir, mat_lib.window_material_by_identifier, 'window_material.json') honeybee_construction_json( source_dir, constr_dir, constr_lib.opaque_construction_by_identifier, 'opaque_construction.json', [os.path.join(extra_folder, 'ground_constructions.json')]) honeybee_construction_json(source_dir, constr_dir, constr_lib.window_construction_by_identifier, 'window_construction.json') # translate the construction sets to honeybee_json src_constr_set_dir = os.path.join(source_dir, 'construction_set') for f in os.listdir(src_constr_set_dir): dest_file = os.path.join(constrset_dir, f) f_path = os.path.join(src_constr_set_dir, f) if os.path.isfile(f_path) and f_path.endswith('.json'): with open(f_path, 'r') as json_file: c_dict = json.load(json_file) hb_dict = {} for c_id in c_dict: base_dict = \ constrset_lib.construction_set_by_identifier(c_id).to_dict(abridged=True) del_keys = [] for key in base_dict: if base_dict[key] is None: del_keys.append(key) elif isinstance(base_dict[key], dict): sub_del_keys = [] for s_key in base_dict[key]: if base_dict[key][s_key] is None: sub_del_keys.append(s_key) for s_key in sub_del_keys: del base_dict[key][s_key] for key in del_keys: del base_dict[key] hb_dict[c_id] = base_dict with open(dest_file, 'w') as fp: json.dump(hb_dict, fp, indent=2) # translate schedules to honeybee json sched_json = os.path.join(source_dir, 'schedule.json') hb_sch_dict = {} with open(sched_json, 'r') as json_file: sch_dict = json.load(json_file) for sch_id in sch_dict: hb_sch_dict[sch_id] = sch_lib.schedule_by_identifier(sch_id).to_dict( abridged=True) # get a string representation and clean it further init_str = json.dumps(hb_sch_dict, indent=2) new_str = re.sub(r'\s*(\d*\.\d*),\s*', r'\1, ', init_str) right_bracket_str = re.sub(r'\s*(])', r'\1', new_str) left_bracket_str = re.sub(r'(\[)\s*', r'\1', right_bracket_str) newer_str = re.sub(r'\[(.\d*),\s*(.\d*)\],\s*', r'[\1, \2], ', left_bracket_str) final_str = re.sub(r'\[(.\d*),\s*(.\d*)\]', r'[\1, \2]', newer_str) # write the data into a file sch_path = os.path.join(sched_dir, 'schedule.json') with open(sch_path, 'w') as fp: fp.write(final_str) # translate the program types to honeybee json src_ptype_dir = os.path.join(source_dir, 'program_type') for f in os.listdir(src_ptype_dir): f_path = os.path.join(src_ptype_dir, f) if os.path.isfile(f_path) and f_path.endswith('.json') \ and not f_path.endswith('registry.json'): with open(f_path, 'r') as json_file: p_dict = json.load(json_file) hb_dict = {} for p_id in p_dict: hb_dict[p_id] = \ program_lib.program_type_by_identifier(p_id).to_dict(abridged=True) dest_file = os.path.join(ptype_dir, f) with open(dest_file, 'w') as fp: json.dump(hb_dict, fp, indent=2) # copy the program registry files over to the data folder for f in os.listdir(src_ptype_dir): f_path = os.path.join(src_ptype_dir, f) if os.path.isfile(f_path) and f_path.endswith('registry.json'): dest_file = os.path.join(ptype_reg_dir, f) shutil.copy(f_path, dest_file) print('Successfully translated OpenStudio JSONs to Honeybee.')
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 = [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)
from honeybee_energy.load.infiltration import Infiltration from honeybee_energy.load.ventilation import Ventilation from honeybee_energy.lib.schedules import schedule_by_identifier from honeybee_energy.lib.programtypes import program_type_by_identifier, \ building_program_type_by_identifier from honeybee_energy.programtype import ProgramType 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)) # get the always on schedule always_on = schedule_by_identifier('Always On') def dup_load(hb_obj, object_name, object_class): """Duplicate a load object assigned to a Room or ProgramType.""" # try to get the load object assgined to the Room or ProgramType try: # assume it's a Room load_obj = hb_obj.properties for attribute in ('energy', object_name): load_obj = getattr(load_obj, attribute) except AttributeError: # it's a ProgramType load_obj = getattr(hb_obj, object_name) load_id = '{}_{}'.format(hb_obj.identifier, object_name) try: # duplicate the load object dup_load = load_obj.duplicate()
def schedule_ruleset_office_occupancy(directory): office_sch = schedule_by_identifier('OfficeLarge BLDG_OCC_SCH') dest_file = os.path.join(directory, 'schedule_ruleset_office_occupancy.json') with open(dest_file, 'w') as fp: json.dump(office_sch.to_dict(True), fp, indent=4)
def calc_room_vent_rates_from_HB(_hb_room, _ghenv): ''' Uses the EP Loads and Schedules to calc the HB Room's annual flowrate ''' # Guard #--------------------------------------------------------------------------- if _hb_room.floor_area == 0: warning = "Something wrong with the floor area - are you sure\n"\ "there is at least one 'Floor' surface making up the Room?" _ghenv.Component.AddRuntimeMessage(ghK.GH_RuntimeMessageLevel.Warning, warning) return None # Pull the Loads from HB Room # --------------------------------------------------------------------------- vent_flow_per_area = _hb_room.properties.energy.ventilation.flow_per_area vent_flow_per_person = _hb_room.properties.energy.ventilation.flow_per_person vent_flow_per_zone = _hb_room.properties.energy.ventilation.flow_per_zone vent_flow_ach = _hb_room.properties.energy.ventilation.air_changes_per_hour people_per_area = _hb_room.properties.energy.people.people_per_area # Pull the Schedules from HB Room #--------------------------------------------------------------------------- week_start_day = 'Sunday' holidays = None start_date, end_date, timestep = Date(1, 1), Date(12, 31), 1 hb_sched_occ = _hb_room.properties.energy.people.occupancy_schedule hb_sched_vent = _hb_room.properties.energy.ventilation.schedule if hb_sched_occ: hb_sched_occ = schedule_by_identifier(hb_sched_occ.identifier) if isinstance(hb_sched_occ, ScheduleRuleset): data_occ = hb_sched_occ.data_collection(timestep, start_date, end_date, week_start_day, holidays, leap_year=False) else: data_occ = (1 for i in range(8760)) if hb_sched_vent: hb_sched_vent = schedule_by_identifier(hb_sched_vent.identifier) if isinstance(hb_sched_vent, ScheduleRuleset): data_vent = hb_sched_vent.data_collection(timestep, start_date, end_date, week_start_day, holidays, leap_year=False) else: data_vent = (1 for i in range(8760)) #--------------------------------------------------------------------------- # Nominal (peak) flow rates (m3/h) based on the HB/EP Load values # m3/s---> m3/h nom_vent_flow_per_area = vent_flow_per_area * _hb_room.floor_area * 60.0 * 60.0 nom_vent_flow_per_zone = vent_flow_per_zone * 60.0 * 60.0 nom_vent_flow_ach = vent_flow_ach * _hb_room.volume nom_vent_flow_per_person = people_per_area * _hb_room.floor_area * vent_flow_per_person * 60.0 * 60.0 nom_vent_flow_total = nom_vent_flow_per_area + nom_vent_flow_per_person + nom_vent_flow_per_zone + nom_vent_flow_ach #--------------------------------------------------------------------------- # Preview results print("The HB Room: '{}' has an average annual airflow of: {:.2f} "\ "m3/h".format(_hb_room.display_name, nom_vent_flow_total) ) print(">Looking at the Honeybee Program parameters:") print(" *Note: These are the values BEFORE any occupany / activity schedule"\ "is applied to reduce this (demand control)" ) print( " *Note: These are the values takes into account the airflow for 'areas', for people, per zone and by ACH." ) print(" Details:") print(" >Reference HB-Room Floor Area used is: {:.2f} m2".format( float(_hb_room.floor_area))) print(" >Reference HB-Room Volume used is: {:.2f} m3".format( float(_hb_room.volume))) print(" >[Ventilation Per Pers: {:.6f} m3/s-prs] x [Floor Area: {:.2f} m2] x [{:.3f} ppl/m2] "\ "x 3600 s/hr = {:.2f} m3/hr".format(vent_flow_per_person, _hb_room.floor_area, people_per_area, nom_vent_flow_per_person) ) print(" >[Ventilation Per Area: {:.6f} m3/s-m2] x [Floor Area: {:.2f} m2] "\ "x 3600 s/hr = {:.2f} m3/hr".format(float(vent_flow_per_area), float(_hb_room.floor_area), float(nom_vent_flow_per_area)) ) print(" >[Ventilation per Zone: {:.6f} m3/s] x 3600 s/hr = "\ "{:.2f} m3/h".format(vent_flow_per_zone, nom_vent_flow_per_zone, ) ) print(" >[Ventilation by ACH: {:.2f} ACH] x [Volume: {:.2f} m3]"\ " = {:.2f} m3/h ".format(vent_flow_ach, _hb_room.volume, nom_vent_flow_ach) ) print(" >[Vent For Area: {:.2f} m3/h] + [Vent For PPL: {:.2f} m3/h]"\ " + [Vent For Zone: {:.2f} m3/h] + [Vent For ACH: {:.2f} m3/h]"\ " = {:.2f} m3/h".format(nom_vent_flow_per_area, vent_flow_per_person, nom_vent_flow_per_zone, nom_vent_flow_ach, nom_vent_flow_total) ) print('- ' * 100) # Annual Average flow rates taking schedules into account #--------------------------------------------------------------------------- total_nom_vent_flow = nom_vent_flow_per_area + nom_vent_flow_per_zone + nom_vent_flow_ach annual_vent_flow_space = sum(total_nom_vent_flow * val for val in data_vent) / 8760 annual_vent_flow_ppl = sum(nom_vent_flow_per_person * val for val in data_occ) / 8760 annual_vent_flow_total = annual_vent_flow_space + annual_vent_flow_ppl Output = namedtuple('Output', ['nominal', 'annual_avg']) output = Output(nom_vent_flow_total, annual_vent_flow_total) return output
'Autosize': autosize, None: autosize } if all_required_inputs(ghenv.Component): # extract any rooms from input Models and duplicate the rooms rooms = [] for hb_obj in _rooms: if isinstance(hb_obj, Model): rooms.extend([room.duplicate() for room in hb_obj.rooms]) else: rooms.append(hb_obj.duplicate()) # get schedules by identifer if they are strings if isinstance(heat_avail_, str): heat_avail_ = schedule_by_identifier(heat_avail_) if isinstance(cool_avail_, str): cool_avail_ = schedule_by_identifier(cool_avail_) # loop through the rooms and adjust their properties hvac_count = 0 for room in rooms: if room.properties.energy.is_conditioned: # check to be sure the assigned HVAC system is an IdealAirSystem if not isinstance(room.properties.energy.hvac, IdealAirSystem): room.properties.energy.add_default_ideal_air() # create the customized ideal air system new_ideal_air = room.properties.energy.hvac.duplicate() if _economizer_ is not None: new_ideal_air.economizer_type = _economizer_
raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e)) try: from honeybee_energy.load.people import People from honeybee_energy.lib.schedules import schedule_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 except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): # make a default People name if none is provided if _name_ is None: name = "People_{}".format(uuid.uuid4()) else: name = clean_and_id_ep_string(_name_) # get the schedules if isinstance(_occupancy_sch, str): _occupancy_sch = schedule_by_identifier(_occupancy_sch) if isinstance(_activity_sch_, str): _activity_sch_ = schedule_by_identifier(_activity_sch_) # create the People object people = People(name, _ppl_per_area, _occupancy_sch, _activity_sch_) if _name_ is not None: people.display_name = _name_
try: # import ladybug_rhino dependencies from ladybug_rhino.grasshopper import all_required_inputs except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): # check that the input _season_scheds align with the _analysis_periods assert len(_season_scheds) == len(_analysis_periods), \ 'Length of the _season_scheds list must match that of the _analysis_periods.' \ '\n{} does not equal {}'.format(len(_season_scheds), len(_analysis_periods)) # start by duplicating the base schedule if isinstance(_base_schedule, str): _base_schedule = schedule_by_identifier(_base_schedule) schedule = _base_schedule.duplicate() schedule.identifier = clean_and_id_ep_string(_name) schedule.display_name = _name # translate the _season_scheds to individual Rules and apply them to the base for season_sch, a_period in zip(_season_scheds, _analysis_periods): if isinstance(season_sch, str): season_sch = schedule_by_identifier(season_sch) season_rules = season_sch.to_rules( a_period.st_time.date, a_period.end_time.date) for rule in reversed(season_rules): # preserve priority order of rules schedule.add_rule(rule) # get the idf strings of the schedule idf_year, idf_week = schedule.to_idf()
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 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 hb_objs = [obj.duplicate() for obj in _hb_objs] # process the input schedule for i, sch in enumerate(_trans_sch): if isinstance(sch, str): _trans_sch[i] = schedule_by_identifier(sch) # error message for unrecognized object error_msg = 'Input _hb_objs must be a Room, Face, Aperture, Door, or Shade. Not {}.' # assign the schedules if len(_trans_sch) == 1: for obj in hb_objs: if isinstance(obj, Shade): obj.properties.energy.transmittance_schedule = _trans_sch[0] elif isinstance(obj, (Aperture, Face, Room, Door)): for shd in obj.shades: shd.properties.energy.transmittance_schedule = _trans_sch[ 0] else: raise TypeError(error_msg.format(type(obj)))
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): ep_constr = shade_construction_by_identifier(ep_constr) hb_shd.properties.energy.construction = ep_constr # try to assign the energyplus transmittance schedule if len(ep_trans_sch_) != 0: ep_trans_sch = longest_list(ep_trans_sch_, j) if isinstance(ep_trans_sch, str): ep_trans_sch = schedule_by_identifier(ep_trans_sch) hb_shd.properties.energy.transmittance_schedule = ep_trans_sch # try to assign the radiance modifier if len(rad_mod_) != 0: rad_mod = longest_list(rad_mod_, j) if isinstance(rad_mod, str): rad_mod = modifier_by_identifier(rad_mod) hb_shd.properties.radiance.modifier = rad_mod shades.append(hb_shd) # collect the final Shades i += 1 # advance the iterator shades = wrap_output(shades)
def schedule_object(schedule): """Get a schedule object by its identifier or return it it it's already a schedule.""" if isinstance(schedule, str): return schedule_by_identifier(schedule) return schedule
def test_schedule_by_identifier(): """Test that all of the schedules in the library can be loaded by identifier.""" for sched in sched_lib.SCHEDULES: sched_from_lib = sched_lib.schedule_by_identifier(sched) assert isinstance(sched_from_lib, ScheduleRuleset)