def test_lighting_average(): """Test the Lighting.average method.""" weekday_office = ScheduleDay('Weekday Office Lighting', [0, 1, 0.5, 0], [Time(0, 0), Time(9, 0), Time(17, 0), Time(19, 0)]) weekday_lobby = ScheduleDay('Weekday Lobby Lighting', [0.1, 1, 0.1], [Time(0, 0), Time(8, 0), Time(20, 0)]) weekend_office = ScheduleDay('Weekend Office Lighting', [0]) weekend_lobby = ScheduleDay('Weekend Office Lighting', [0.1]) wknd_office_rule = ScheduleRule(weekend_office, apply_saturday=True, apply_sunday=True) wknd_lobby_rule = ScheduleRule(weekend_lobby, apply_saturday=True, apply_sunday=True) office_schedule = ScheduleRuleset('Office Lighting', weekday_office, [wknd_office_rule], schedule_types.fractional) lobby_schedule = ScheduleRuleset('Lobby Lighting', weekday_lobby, [wknd_lobby_rule], schedule_types.fractional) office_lights = Lighting('Office Lighting', 10, office_schedule, 0, 0.3, 0.3) lobby_lights = Lighting('Lobby Lighting', 6, lobby_schedule, 0.1, 0.4, 0.2) office_avg = Lighting.average('Office Average Lighting', [office_lights, lobby_lights]) assert office_avg.watts_per_area == pytest.approx(8, rel=1e-3) assert office_avg.return_air_fraction == pytest.approx(0.05, rel=1e-3) assert office_avg.radiant_fraction == pytest.approx(0.35, rel=1e-3) assert office_avg.visible_fraction == pytest.approx(0.25, rel=1e-3) week_vals = office_avg.schedule.values(end_date=Date(1, 7)) avg_vals = [0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.75, 0.75, 0.5, 0.05, 0.05, 0.05, 0.05] assert week_vals[:24] == [0.05] * 24 assert week_vals[24:48] == avg_vals
def test_lighting_equality(): """Test the equality of Lighting objects.""" weekday_office = ScheduleDay( 'Weekday Office Lighting', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) saturday_office = ScheduleDay( 'Saturday Office Lighting', [0, 0.25, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) weekend_rule = ScheduleRule(saturday_office) weekend_rule.apply_weekend = True schedule = ScheduleRuleset('Office Lighting', weekday_office, [weekend_rule], schedule_types.fractional) lighting = Lighting('Open Office Zone Lighting', 10, schedule) lighting_dup = lighting.duplicate() lighting_alt = Lighting( 'Open Office Zone Lighting', 10, ScheduleRuleset.from_constant_value('Constant', 1, schedule_types.fractional)) assert lighting is lighting assert lighting is not lighting_dup assert lighting == lighting_dup lighting_dup.watts_per_area = 6 assert lighting != lighting_dup assert lighting != lighting_alt
def test_lighting_lockability(): """Test the lockability of Lighting objects.""" weekday_office = ScheduleDay( 'Weekday Office Lighting', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) saturday_office = ScheduleDay( 'Saturday Office Lighting', [0, 0.25, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) weekend_rule = ScheduleRule(saturday_office) weekend_rule.apply_weekend = True schedule = ScheduleRuleset('Office Lighting', weekday_office, [weekend_rule], schedule_types.fractional) lighting = Lighting('Open Office Zone Lighting', 10, schedule) lighting.watts_per_area = 6 lighting.lock() with pytest.raises(AttributeError): lighting.watts_per_area = 8 with pytest.raises(AttributeError): lighting.schedule.default_day_schedule.remove_value_by_time(Time( 17, 0)) lighting.unlock() lighting.watts_per_area = 8 with pytest.raises(AttributeError): lighting.schedule.default_day_schedule.remove_value_by_time(Time( 17, 0))
def test_lighting_setability(): """Test the setting of properties of Lighting.""" simple_office = ScheduleDay( 'Simple Weekday Light', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) schedule = ScheduleRuleset('Office Lighting', simple_office, None, schedule_types.fractional) constant = ScheduleRuleset.from_constant_value('Constant Light', 1, schedule_types.fractional) lighting = Lighting('Open Office Zone Lighting', 10, schedule) lighting.identifier = 'Office Zone Lighting' assert lighting.identifier == 'Office Zone Lighting' lighting.watts_per_area = 6 assert lighting.watts_per_area == 6 lighting.schedule = constant assert lighting.schedule == constant assert lighting.schedule.values() == [1] * 8760 lighting.return_air_fraction = 0.1 assert lighting.return_air_fraction == 0.1 lighting.radiant_fraction = 0.4 assert lighting.radiant_fraction == 0.4 lighting.visible_fraction = 0.2 assert lighting.visible_fraction == 0.2 lighting.baseline_watts_per_area = 5.0 assert lighting.baseline_watts_per_area == 5.0
def test_program_type_dict_methods(): """Test the to/from dict methods.""" simple_office = ScheduleDay( 'Simple Weekday Occupancy', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) occ_schedule = ScheduleRuleset('Office Occupancy Schedule', simple_office, None, schedule_types.fractional) light_schedule = occ_schedule.duplicate() light_schedule.identifier = 'Office Lighting-Equip Schedule' light_schedule.default_day_schedule.values = [0.25, 1, 0.25] equip_schedule = light_schedule.duplicate() inf_schedule = ScheduleRuleset.from_constant_value( 'Infiltration Schedule', 1, schedule_types.fractional) heat_setpt = ScheduleRuleset.from_constant_value( 'Office Heating Schedule', 21, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Office Cooling Schedule', 24, schedule_types.temperature) people = People('Open Office People', 0.05, occ_schedule) lighting = Lighting('Open Office Lighting', 10, light_schedule) equipment = ElectricEquipment('Open Office Equipment', 10, equip_schedule) infiltration = Infiltration('Office Infiltration', 0.00015, inf_schedule) ventilation = Ventilation('Office Ventilation', 0.0025, 0.0003) setpoint = Setpoint('Office Setpoints', heat_setpt, cool_setpt) office_program = ProgramType('Open Office Program', people, lighting, equipment, None, None, infiltration, ventilation, setpoint) prog_dict = office_program.to_dict() new_office_program = ProgramType.from_dict(prog_dict) assert new_office_program == office_program assert prog_dict == new_office_program.to_dict()
def dict_to_load(load_dict, raise_exception=True): """Get a Python object of any Load from a dictionary. Args: load_dict: A dictionary of any Honeybee energy load. Note that this should be a non-abridged dictionary to be valid. raise_exception: Boolean to note whether an excpetion should be raised if the object is not identified as a load. Default: True. Returns: A Python object derived from the input load_dict. """ try: # get the type key from the dictionary load_type = load_dict['type'] except KeyError: raise ValueError('Load dictionary lacks required "type" key.') if load_type == 'People': return People.from_dict(load_dict) elif load_type == 'Lighting': return Lighting.from_dict(load_dict) elif load_type == 'ElectricEquipment': return ElectricEquipment.from_dict(load_dict) elif load_type == 'GasEquipment': return GasEquipment.from_dict(load_dict) elif load_type == 'Infiltration': return Infiltration.from_dict(load_dict) elif load_type == 'Ventilation': return Ventilation.from_dict(load_dict) elif load_type == 'Setpoint': return Setpoint.from_dict(load_dict) elif raise_exception: raise ValueError( '{} is not a recognized energy Load type'.format(load_type))
def test_lighting_dict_methods(): """Test the to/from dict methods.""" weekday_office = ScheduleDay('Weekday Office Lighting', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) saturday_office = ScheduleDay('Saturday Office Lighting', [0, 0.25, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) weekend_rule = ScheduleRule(saturday_office) weekend_rule.apply_weekend = True schedule = ScheduleRuleset('Office Lighting', weekday_office, [weekend_rule], schedule_types.fractional) lighting = Lighting('Open Office Zone Lighting', 10, schedule) light_dict = lighting.to_dict() new_lighting = Lighting.from_dict(light_dict) assert new_lighting == lighting assert light_dict == new_lighting.to_dict()
def test_program_type_setability(): """Test the setting of properties of ProgramType.""" simple_office = ScheduleDay( 'Simple Weekday Occupancy', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) occ_schedule = ScheduleRuleset('Office Occupancy Schedule', simple_office, None, schedule_types.fractional) light_schedule = occ_schedule.duplicate() light_schedule.identifier = 'Office Lighting-Equip Schedule' light_schedule.default_day_schedule.values = [0.25, 1, 0.25] equip_schedule = light_schedule.duplicate() inf_schedule = ScheduleRuleset.from_constant_value( 'Infiltration Schedule', 1, schedule_types.fractional) heat_setpt = ScheduleRuleset.from_constant_value( 'Office Heating Schedule', 21, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Office Cooling Schedule', 24, schedule_types.temperature) people = People('Open Office People', 0.05, occ_schedule) lighting = Lighting('Open Office Lighting', 10, light_schedule) equipment = ElectricEquipment('Open Office Equipment', 10, equip_schedule) infiltration = Infiltration('Office Infiltration', 0.00015, inf_schedule) ventilation = Ventilation('Office Ventilation', 0.0025, 0.0003) setpoint = Setpoint('Office Setpoints', heat_setpt, cool_setpt) office_program = ProgramType('Open Office Program') assert office_program.identifier == 'Open Office Program' office_program.identifier = 'Office Program' assert office_program.identifier == 'Office Program' assert office_program.people is None office_program.people = people assert office_program.people == people assert office_program.lighting is None office_program.lighting = lighting assert office_program.lighting == lighting assert office_program.electric_equipment is None office_program.electric_equipment = equipment assert office_program.electric_equipment == equipment assert office_program.infiltration is None office_program.infiltration = infiltration assert office_program.infiltration == infiltration assert office_program.ventilation is None office_program.ventilation = ventilation assert office_program.ventilation == ventilation assert office_program.setpoint is None office_program.setpoint = setpoint assert office_program.setpoint == setpoint with pytest.raises(AssertionError): office_program.people = lighting with pytest.raises(AssertionError): office_program.lighting = equipment with pytest.raises(AssertionError): office_program.electric_equipment = people with pytest.raises(AssertionError): office_program.infiltration = people with pytest.raises(AssertionError): office_program.ventilation = setpoint with pytest.raises(AssertionError): office_program.setpoint = ventilation
def test_lighting_init_from_idf(): """Test the initialization of Lighting from_idf.""" weekday_office = ScheduleDay('Weekday Office Lighting', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) saturday_office = ScheduleDay('Saturday Office Lighting', [0, 0.25, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) weekend_rule = ScheduleRule(saturday_office) weekend_rule.apply_weekend = True schedule = ScheduleRuleset('Office Lighting', weekday_office, [weekend_rule], schedule_types.fractional) lighting = Lighting('Open Office Zone Lighting', 10, schedule) sched_dict = {schedule.identifier: schedule} zone_id = 'Test Zone' idf_str = lighting.to_idf(zone_id) rebuilt_lighting, rebuilt_zone_id = Lighting.from_idf(idf_str, sched_dict) assert lighting == rebuilt_lighting assert zone_id == rebuilt_zone_id
def test_program_type_lockability(): """Test the lockability of ProgramType objects.""" simple_office = ScheduleDay('Simple Weekday Occupancy', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) light_schedule = ScheduleRuleset('Office Lighting-Equip Schedule', simple_office, None, schedule_types.fractional) lighting = Lighting('Open Office Lighting', 10, light_schedule) led_lighting = Lighting('LED Office Lighting', 5, light_schedule) office_program = ProgramType('Open Office Program', lighting=lighting) office_program.lighting.watts_per_area = 6 office_program.lock() with pytest.raises(AttributeError): office_program.lighting.watts_per_area = 8 with pytest.raises(AttributeError): office_program.lighting = led_lighting office_program.unlock() office_program.lighting.watts_per_area = 8 office_program.lighting = led_lighting
def test_program_type_equality(): """Test the equality of ProgramType objects.""" simple_office = ScheduleDay( 'Simple Weekday Occupancy', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) occ_schedule = ScheduleRuleset('Office Occupancy Schedule', simple_office, None, schedule_types.fractional) light_schedule = occ_schedule.duplicate() light_schedule.identifier = 'Office Lighting-Equip Schedule' light_schedule.default_day_schedule.values = [0.25, 1, 0.25] equip_schedule = light_schedule.duplicate() inf_schedule = ScheduleRuleset.from_constant_value( 'Infiltration Schedule', 1, schedule_types.fractional) heat_setpt = ScheduleRuleset.from_constant_value( 'Office Heating Schedule', 21, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Office Cooling Schedule', 24, schedule_types.temperature) people = People('Open Office People', 0.05, occ_schedule) lighting = Lighting('Open Office Lighting', 10, light_schedule) led_lighting = Lighting('LED Office Lighting', 5, light_schedule) equipment = ElectricEquipment('Open Office Equipment', 10, equip_schedule) infiltration = Infiltration('Office Infiltration', 0.00015, inf_schedule) ventilation = Ventilation('Office Ventilation', 0.0025, 0.0003) setpoint = Setpoint('Office Setpoints', heat_setpt, cool_setpt) office_program = ProgramType('Open Office Program', people, lighting, equipment, None, None, infiltration, ventilation, setpoint) office_program_dup = office_program.duplicate() office_program_alt = ProgramType('Open Office Program', people, led_lighting, equipment, None, None, infiltration, ventilation, setpoint) assert office_program is office_program assert office_program is not office_program_dup assert office_program == office_program_dup office_program_dup.people.people_per_area = 0.1 assert office_program != office_program_dup assert office_program != office_program_alt
def test_check_duplicate_program_type_identifiers(): """Test the check_duplicate_program_type_identifiers method.""" pts_1 = (Point3D(0, 0, 3), Point3D(0, 10, 3), Point3D(10, 10, 3), Point3D(10, 0, 3)) pts_2 = (Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(20, 10, 3), Point3D(20, 0, 3)) room2d_1 = Room2D('Office1', Face3D(pts_1), 3) room2d_2 = Room2D('Office2', Face3D(pts_2), 3) story = Story('OfficeFloor', [room2d_1, room2d_2]) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.multiplier = 4 for room in story.room_2ds: room.properties.energy.program_type = office_program room.properties.energy.add_default_ideal_air() building = Building('OfficeBuilding', [story]) building.separate_top_bottom_floors() attic_program_type = plenum_program.duplicate() attic_program_type.identifier = 'Attic Space' schedule = ScheduleRuleset.from_constant_value('Always Dim', 1, schedule_types.fractional) lighting = Lighting('Attic Lighting', 3, schedule) attic_program_type.lighting = lighting building.unique_room_2ds[ -1].properties.energy.program_type = attic_program_type building.unique_room_2ds[ -2].properties.energy.program_type = attic_program_type tree_canopy_geo1 = Face3D.from_regular_polygon(6, 6, Plane(o=Point3D(5, -10, 6))) tree_canopy_geo2 = Face3D.from_regular_polygon( 6, 2, Plane(o=Point3D(-5, -10, 3))) tree_canopy = ContextShade('TreeCanopy', [tree_canopy_geo1, tree_canopy_geo2]) model = Model('NewDevelopment', [building], [tree_canopy]) assert model.properties.energy.check_duplicate_program_type_identifiers( False) attic_program_type.unlock() attic_program_type.identifier = office_program.identifier attic_program_type.lock() assert not model.properties.energy.check_duplicate_program_type_identifiers( False) with pytest.raises(ValueError): model.properties.energy.check_duplicate_program_type_identifiers(True)
def test_lighting_init(): """Test the initialization of Lighting and basic properties.""" simple_office = ScheduleDay('Simple Weekday', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) schedule = ScheduleRuleset('Office Lighting', simple_office, None, schedule_types.fractional) lighting = Lighting('Open Office Zone Lighting', 10, schedule) str(lighting) # test the string representation assert lighting.identifier == 'Open Office Zone Lighting' assert lighting.watts_per_area == 10 assert lighting.schedule.identifier == 'Office Lighting' assert lighting.schedule.schedule_type_limit == schedule_types.fractional assert lighting.schedule == schedule assert lighting.return_air_fraction == 0 assert lighting.radiant_fraction == 0.32 assert lighting.visible_fraction == 0.25
def test_program_type_init(): """Test the initialization of ProgramType and basic properties.""" simple_office = ScheduleDay( 'Simple Weekday Occupancy', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) occ_schedule = ScheduleRuleset('Office Occupancy Schedule', simple_office, None, schedule_types.fractional) light_schedule = occ_schedule.duplicate() light_schedule.identifier = 'Office Lighting-Equip Schedule' light_schedule.default_day_schedule.values = [0.25, 1, 0.25] equip_schedule = light_schedule.duplicate() inf_schedule = ScheduleRuleset.from_constant_value( 'Infiltration Schedule', 1, schedule_types.fractional) heat_setpt = ScheduleRuleset.from_constant_value( 'Office Heating Schedule', 21, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Office Cooling Schedule', 24, schedule_types.temperature) people = People('Open Office People', 0.05, occ_schedule) lighting = Lighting('Open Office Lighting', 10, light_schedule) equipment = ElectricEquipment('Open Office Equipment', 10, equip_schedule) infiltration = Infiltration('Office Infiltration', 0.00015, inf_schedule) ventilation = Ventilation('Office Ventilation', 0.0025, 0.0003) setpoint = Setpoint('Office Setpoints', heat_setpt, cool_setpt) office_program = ProgramType('Open Office Program', people, lighting, equipment, None, None, infiltration, ventilation, setpoint) str(office_program) # test the string representation assert office_program.identifier == 'Open Office Program' assert isinstance(office_program.people, People) assert office_program.people == people assert isinstance(office_program.lighting, Lighting) assert office_program.lighting == lighting assert isinstance(office_program.electric_equipment, ElectricEquipment) assert office_program.electric_equipment == equipment assert office_program.gas_equipment is None assert isinstance(office_program.infiltration, Infiltration) assert office_program.infiltration == infiltration assert isinstance(office_program.ventilation, Ventilation) assert office_program.ventilation == ventilation assert isinstance(office_program.setpoint, Setpoint) assert office_program.setpoint == setpoint assert len(office_program.schedules) == 7 assert len(office_program.schedules_unique) == 6
def test_program_type_diversify(): """Test the diversify methods.""" simple_office = ScheduleDay( 'Simple Weekday Occupancy', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) occ_schedule = ScheduleRuleset('Office Occupancy Schedule', simple_office, None, schedule_types.fractional) light_schedule = occ_schedule.duplicate() light_schedule.identifier = 'Office Lighting-Equip Schedule' light_schedule.default_day_schedule.values = [0.25, 1, 0.25] equip_schedule = light_schedule.duplicate() inf_schedule = ScheduleRuleset.from_constant_value( 'Infiltration Schedule', 1, schedule_types.fractional) heat_setpt = ScheduleRuleset.from_constant_value( 'Office Heating Schedule', 21, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Office Cooling Schedule', 24, schedule_types.temperature) people = People('Open Office People', 0.05, occ_schedule) lighting = Lighting('Open Office Lighting', 10, light_schedule) equipment = ElectricEquipment('Open Office Equipment', 10, equip_schedule) infiltration = Infiltration('Office Infiltration', 0.00015, inf_schedule) ventilation = Ventilation('Office Ventilation', 0.0025, 0.0003) setpoint = Setpoint('Office Setpoints', heat_setpt, cool_setpt) office_program = ProgramType('Open Office Program', people, lighting, equipment, None, None, infiltration, ventilation, setpoint) div_programs = office_program.diversify(10) assert len(div_programs) == 10 for prog in div_programs: assert isinstance(prog, ProgramType) assert prog.people.people_per_area != people.people_per_area assert prog.lighting.watts_per_area != lighting.watts_per_area assert prog.electric_equipment.watts_per_area != equipment.watts_per_area assert prog.infiltration.flow_per_exterior_area != \ infiltration.flow_per_exterior_area div_programs = office_program.diversify(10, schedule_offset=0) for prog in div_programs: assert prog.people.occupancy_schedule == people.occupancy_schedule
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 Lighting name if none is provided name = clean_and_id_ep_string('Lighting') if _name_ is None else \ clean_ep_string(_name_) # get the schedule if isinstance(_schedule, str): _schedule = schedule_by_identifier(_schedule) # get default radiant, visible, and return fractions return_fract_ = return_fract_ if return_fract_ is not None else 0.0 _radiant_fract_ = _radiant_fract_ if _radiant_fract_ is not None else 0.32 _visible_fract_ = _visible_fract_ if _visible_fract_ is not None else 0.25 # create the Lighting object lighting = Lighting(name, _watts_per_area, _schedule, return_fract_, _radiant_fract_, _visible_fract_) if _name_ is not None: lighting.display_name = _name_ if baseline_ is not None: lighting.baseline_watts_per_area = baseline_
def test_to_honeybee(): """Test the Model to_honeybee method.""" pts_1 = (Point3D(0, 0, 3), Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(0, 10, 3)) pts_2 = (Point3D(10, 0, 3), Point3D(20, 0, 3), Point3D(20, 10, 3), Point3D(10, 10, 3)) pts_3 = (Point3D(0, 20, 3), Point3D(20, 20, 3), Point3D(20, 30, 3), Point3D(0, 30, 3)) room2d_1 = Room2D('Office1', Face3D(pts_1), 3) room2d_2 = Room2D('Office2', Face3D(pts_2), 3) room2d_3 = Room2D('Office3', Face3D(pts_3), 3) story_big = Story('OfficeFloorBig', [room2d_3]) story = Story('OfficeFloor', [room2d_1, room2d_2]) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.multiplier = 4 building = Building('OfficeBuilding', [story]) building.separate_top_bottom_floors() story_big.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story_big.multiplier = 4 building_big = Building('OfficeBuildingBig', [story_big]) building_big.separate_top_bottom_floors() attic_program_type = plenum_program.duplicate() attic_program_type.identifier = 'Attic Space' schedule = ScheduleRuleset.from_constant_value('Always Dim', 1, schedule_types.fractional) lighting = Lighting('Attic Lighting', 3, schedule) attic_program_type.lighting = lighting building.unique_room_2ds[ -1].properties.energy.program_type = attic_program_type building.unique_room_2ds[ -2].properties.energy.program_type = attic_program_type constr_set = ConstructionSet('Attic Construction Set') polyiso = EnergyMaterial('PolyIso', 0.2, 0.03, 43, 1210, 'MediumRough') roof_constr = OpaqueConstruction('Attic Roof Construction', [roof_membrane, polyiso, wood]) floor_constr = OpaqueConstruction('Attic Floor Construction', [wood, insulation, wood]) constr_set.floor_set.interior_construction = floor_constr constr_set.roof_ceiling_set.exterior_construction = roof_constr building.unique_room_2ds[ -1].properties.energy.construction_set = constr_set building.unique_room_2ds[ -2].properties.energy.construction_set = constr_set tree_canopy_geo1 = Face3D.from_regular_polygon(6, 6, Plane(o=Point3D(5, -10, 6))) tree_canopy_geo2 = Face3D.from_regular_polygon( 6, 2, Plane(o=Point3D(-5, -10, 3))) tree_canopy = ContextShade('TreeCanopy', [tree_canopy_geo1, tree_canopy_geo2]) bright_leaves = ShadeConstruction('Bright Light Leaves', 0.5, 0.5, True) tree_canopy.properties.energy.construction = bright_leaves tree_trans = ScheduleRuleset.from_constant_value('Tree Transmittance', 0.5, schedule_types.fractional) tree_canopy.properties.energy.transmittance_schedule = tree_trans model = Model('NewDevelopment', [building, building_big], [tree_canopy]) hb_models = model.to_honeybee('Building', 10, False, tolerance=0.01) assert len(hb_models) == 2 assert polyiso in hb_models[0].properties.energy.materials assert roof_constr in hb_models[0].properties.energy.constructions assert floor_constr in hb_models[0].properties.energy.constructions assert constr_set in hb_models[0].properties.energy.construction_sets assert hb_models[0].rooms[ -1].properties.energy.construction_set == constr_set assert polyiso not in hb_models[1].properties.energy.materials assert roof_constr not in hb_models[1].properties.energy.constructions assert floor_constr not in hb_models[1].properties.energy.constructions assert constr_set not in hb_models[1].properties.energy.construction_sets assert schedule in hb_models[0].properties.energy.schedules assert attic_program_type in hb_models[0].properties.energy.program_types assert hb_models[0].rooms[ -1].properties.energy.program_type == attic_program_type assert schedule not in hb_models[1].properties.energy.schedules assert attic_program_type not in hb_models[ 1].properties.energy.program_types assert bright_leaves in hb_models[0].properties.energy.constructions assert tree_trans in hb_models[0].properties.energy.schedules assert hb_models[0].orphaned_shades[ -1].properties.energy.construction == bright_leaves assert hb_models[0].orphaned_shades[ -1].properties.energy.transmittance_schedule == tree_trans assert bright_leaves not in hb_models[-1].properties.energy.constructions assert tree_trans not in hb_models[-1].properties.energy.schedules
# and auto-generate schedules if they were not loaded from default.idf try: plenum_program = _json_program_types['Plenum'] except KeyError: plenum_program = ProgramType('Plenum') plenum_program.lock() _json_program_types['Plenum'] = plenum_program try: office_program = _json_program_types['Generic Office Program'] except KeyError: if _s.generic_office_occupancy is not None: people = People('Generic Office People', 0.0565, _s.generic_office_occupancy, _s.generic_office_activity) lighting = Lighting('Generic Office Lighting', 10.55, _s.generic_office_lighting, 0.0, 0.7, 0.2) equipment = ElectricEquipment('Generic Office Equipment', 10.33, _s.generic_office_equipment, 0.5) infiltration = Infiltration('Generic Office Infiltration', 0.0002266, _s.generic_office_infiltration) ventilation = Ventilation('Generic Office Ventilation', 0.00236, 0.000305) setpoint = Setpoint('Generic Office Setpoints', _s.generic_office_heating, _s.generic_office_cooling) office_program = ProgramType('Generic Office Program', people, lighting, equipment, None, infiltration, ventilation, setpoint) plenum_program.lock() else: office_program = None
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)
def test_averaged_program_type(): """Test the averaged_program_type method.""" pts_1 = (Point3D(0, 0, 3), Point3D(0, 10, 3), Point3D(10, 10, 3), Point3D(10, 0, 3)) pts_2 = (Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(20, 10, 3), Point3D(20, 0, 3)) room2d_1 = Room2D('Office1', Face3D(pts_1), 3) room2d_2 = Room2D('Office2', Face3D(pts_2), 3) simple_office = ScheduleDay('Simple Weekday Occupancy', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) occ_schedule = ScheduleRuleset('Office Occupancy Schedule', simple_office, None, schedule_types.fractional) light_schedule = occ_schedule.duplicate() light_schedule.identifier = 'Office Lighting-Equip Schedule' light_schedule.default_day_schedule.values = [0.25, 1, 0.25] equip_schedule = light_schedule.duplicate() inf_schedule = ScheduleRuleset.from_constant_value( 'Infiltration Schedule', 1, schedule_types.fractional) heat_setpt = ScheduleRuleset.from_constant_value( 'Office Heating Schedule', 21, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Office Cooling Schedule', 24, schedule_types.temperature) people = People('Open Office People', 0.05, occ_schedule) lighting = Lighting('Open Office Lighting', 10, light_schedule) equipment = ElectricEquipment('Open Office Equipment', 10, equip_schedule) infiltration = Infiltration('Office Infiltration', 0.0002, inf_schedule) ventilation = Ventilation('Office Ventilation', 0.005, 0.0003) setpoint = Setpoint('Office Setpoints', heat_setpt, cool_setpt) office_program = ProgramType('Open Office Program', people, lighting, equipment, None, None, infiltration, ventilation, setpoint) plenum_program = ProgramType('Plenum Program') room2d_1.properties.energy.program_type = office_program room2d_2.properties.energy.program_type = plenum_program story = Story('OfficeFloor', [room2d_1, room2d_2]) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.multiplier = 4 building = Building('OfficeBuilding', [story]) office_avg = building.properties.energy.averaged_program_type('Office Avg Program') assert office_avg.people.people_per_area == pytest.approx(0.025, rel=1e-3) assert office_avg.people.occupancy_schedule.default_day_schedule.values == \ office_program.people.occupancy_schedule.default_day_schedule.values assert office_avg.people.latent_fraction == \ office_program.people.latent_fraction assert office_avg.people.radiant_fraction == \ office_program.people.radiant_fraction assert office_avg.lighting.watts_per_area == pytest.approx(5, rel=1e-3) assert office_avg.lighting.schedule.default_day_schedule.values == \ office_program.lighting.schedule.default_day_schedule.values assert office_avg.lighting.return_air_fraction == \ office_program.lighting.return_air_fraction assert office_avg.lighting.radiant_fraction == \ office_program.lighting.radiant_fraction assert office_avg.lighting.visible_fraction == \ office_program.lighting.visible_fraction assert office_avg.electric_equipment.watts_per_area == pytest.approx(5, rel=1e-3) assert office_avg.electric_equipment.schedule.default_day_schedule.values == \ office_program.electric_equipment.schedule.default_day_schedule.values assert office_avg.electric_equipment.radiant_fraction == \ office_program.electric_equipment.radiant_fraction assert office_avg.electric_equipment.latent_fraction == \ office_program.electric_equipment.latent_fraction assert office_avg.electric_equipment.lost_fraction == \ office_program.electric_equipment.lost_fraction assert office_avg.gas_equipment is None assert office_avg.infiltration.flow_per_exterior_area == \ pytest.approx(0.0001, rel=1e-3) assert office_avg.infiltration.schedule.default_day_schedule.values == \ office_program.infiltration.schedule.default_day_schedule.values assert office_avg.infiltration.constant_coefficient == \ office_program.infiltration.constant_coefficient assert office_avg.infiltration.temperature_coefficient == \ office_program.infiltration.temperature_coefficient assert office_avg.infiltration.velocity_coefficient == \ office_program.infiltration.velocity_coefficient assert office_avg.ventilation.flow_per_person == pytest.approx(0.0025, rel=1e-3) assert office_avg.ventilation.flow_per_area == pytest.approx(0.00015, rel=1e-3) assert office_avg.ventilation.flow_per_zone == pytest.approx(0, rel=1e-3) assert office_avg.ventilation.air_changes_per_hour == pytest.approx(0, rel=1e-3) assert office_avg.ventilation.schedule is None assert office_avg.setpoint.heating_setpoint == pytest.approx(21, rel=1e-3) assert office_avg.setpoint.cooling_setpoint == pytest.approx(24, rel=1e-3)
def model_complete_simple(directory): """Generate simple Model sample.""" pts_1 = (Point3D(0, 0, 3), Point3D(0, 10, 3), Point3D(10, 10, 3), Point3D(10, 0, 3)) pts_2 = (Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(20, 10, 3), Point3D(20, 0, 3)) room2d_1 = Room2D('Office 1', Face3D(pts_1), 3) room2d_2 = Room2D('Office 2', Face3D(pts_2), 3) story = Story('Office Floor', [room2d_1, room2d_2]) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.multiplier = 4 for room in story.room_2ds: room.properties.energy.program_type = office_program room.properties.energy.add_default_ideal_air() building = Building('Office Building', [story]) building.separate_top_bottom_floors() attic_program_type = plenum_program.duplicate() attic_program_type.name = 'Attic Space' schedule = ScheduleRuleset.from_constant_value('Always Dim', 1, schedule_types.fractional) lighting = Lighting('Attic Lighting', 3, schedule) attic_program_type.lighting = lighting building.unique_room_2ds[ -1].properties.energy.program_type = attic_program_type building.unique_room_2ds[ -2].properties.energy.program_type = attic_program_type constr_set = ConstructionSet('Attic Construction Set') polyiso = EnergyMaterial('PolyIso', 0.2, 0.03, 43, 1210, 'MediumRough') roof_constr = OpaqueConstruction('Attic Roof Construction', [roof_membrane, polyiso, wood]) floor_constr = OpaqueConstruction('Attic Floor Construction', [wood, insulation, wood]) constr_set.floor_set.interior_construction = floor_constr constr_set.roof_ceiling_set.exterior_construction = roof_constr building.unique_room_2ds[ -1].properties.energy.construction_set = constr_set building.unique_room_2ds[ -2].properties.energy.construction_set = constr_set tree_canopy_geo1 = Face3D.from_regular_polygon(6, 6, Plane(o=Point3D(5, -10, 6))) tree_canopy_geo2 = Face3D.from_regular_polygon( 6, 2, Plane(o=Point3D(-5, -10, 3))) tree_canopy = ContextShade('Tree Canopy', [tree_canopy_geo1, tree_canopy_geo2]) bright_leaves = ShadeConstruction('Bright Light Leaves', 0.5, 0.5, True) tree_canopy.properties.energy.construction = bright_leaves tree_trans = ScheduleRuleset.from_constant_value('Tree Transmittance', 0.5, schedule_types.fractional) tree_canopy.properties.energy.transmittance_schedule = tree_trans model = Model('New Development', [building], [tree_canopy]) model.north_angle = 15 dest_file = os.path.join(directory, 'model_complete_simple.json') with open(dest_file, 'w') as fp: json.dump(model.to_dict(), fp, indent=4)
def test_program_type_average(): """Test the ProgramType.average method.""" simple_office = ScheduleDay( 'Simple Weekday Occupancy', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) occ_schedule = ScheduleRuleset('Office Occupancy Schedule', simple_office, None, schedule_types.fractional) light_schedule = occ_schedule.duplicate() light_schedule.identifier = 'Office Lighting-Equip Schedule' light_schedule.default_day_schedule.values = [0.25, 1, 0.25] equip_schedule = light_schedule.duplicate() inf_schedule = ScheduleRuleset.from_constant_value( 'Infiltration Schedule', 1, schedule_types.fractional) heat_setpt = ScheduleRuleset.from_constant_value( 'Office Heating Schedule', 21, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Office Cooling Schedule', 24, schedule_types.temperature) people = People('Open Office People', 0.05, occ_schedule) lighting = Lighting('Open Office Lighting', 10, light_schedule) equipment = ElectricEquipment('Open Office Equipment', 10, equip_schedule) infiltration = Infiltration('Office Infiltration', 0.0002, inf_schedule) ventilation = Ventilation('Office Ventilation', 0.005, 0.0003) setpoint = Setpoint('Office Setpoints', heat_setpt, cool_setpt) office_program = ProgramType('Open Office Program', people, lighting, equipment, None, None, infiltration, ventilation, setpoint) plenum_program = ProgramType('Plenum Program') office_avg = ProgramType.average('Office Average Program', [office_program, plenum_program]) assert office_avg.people.people_per_area == pytest.approx(0.025, rel=1e-3) assert office_avg.people.occupancy_schedule.default_day_schedule.values == \ office_program.people.occupancy_schedule.default_day_schedule.values assert office_avg.people.latent_fraction == \ office_program.people.latent_fraction assert office_avg.people.radiant_fraction == \ office_program.people.radiant_fraction assert office_avg.lighting.watts_per_area == pytest.approx(5, rel=1e-3) assert office_avg.lighting.schedule.default_day_schedule.values == \ office_program.lighting.schedule.default_day_schedule.values assert office_avg.lighting.return_air_fraction == \ office_program.lighting.return_air_fraction assert office_avg.lighting.radiant_fraction == \ office_program.lighting.radiant_fraction assert office_avg.lighting.visible_fraction == \ office_program.lighting.visible_fraction assert office_avg.electric_equipment.watts_per_area == pytest.approx( 5, rel=1e-3) assert office_avg.electric_equipment.schedule.default_day_schedule.values == \ office_program.electric_equipment.schedule.default_day_schedule.values assert office_avg.electric_equipment.radiant_fraction == \ office_program.electric_equipment.radiant_fraction assert office_avg.electric_equipment.latent_fraction == \ office_program.electric_equipment.latent_fraction assert office_avg.electric_equipment.lost_fraction == \ office_program.electric_equipment.lost_fraction assert office_avg.gas_equipment is None assert office_avg.infiltration.flow_per_exterior_area == \ pytest.approx(0.0001, rel=1e-3) assert office_avg.infiltration.schedule.default_day_schedule.values == \ office_program.infiltration.schedule.default_day_schedule.values assert office_avg.infiltration.constant_coefficient == \ office_program.infiltration.constant_coefficient assert office_avg.infiltration.temperature_coefficient == \ office_program.infiltration.temperature_coefficient assert office_avg.infiltration.velocity_coefficient == \ office_program.infiltration.velocity_coefficient assert office_avg.ventilation.flow_per_person == pytest.approx(0.0025, rel=1e-3) assert office_avg.ventilation.flow_per_area == pytest.approx(0.00015, rel=1e-3) assert office_avg.ventilation.flow_per_zone == pytest.approx(0, rel=1e-3) assert office_avg.ventilation.air_changes_per_hour == pytest.approx( 0, rel=1e-3) assert office_avg.ventilation.schedule is None assert office_avg.setpoint.heating_setpoint == pytest.approx(21, rel=1e-3) assert office_avg.setpoint.cooling_setpoint == pytest.approx(24, rel=1e-3)