def test_people_equality(): """Test the equality of People objects.""" weekday_office = ScheduleDay( 'Weekday Office Occupancy', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) saturday_office = ScheduleDay( 'Saturday Office Occupancy', [0, 0.25, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) weekend_rule = ScheduleRule(saturday_office) weekend_rule.apply_weekend = True occ_schedule = ScheduleRuleset('Office Occupancy', weekday_office, [weekend_rule], schedule_types.fractional) people = People('Open Office Zone People', 0.05, occ_schedule) people_dup = people.duplicate() people_alt = People( 'Open Office Zone People', 0.05, ScheduleRuleset.from_constant_value('Constant', 1, schedule_types.fractional)) assert people is people assert people is not people_dup assert people == people_dup people_dup.people_per_area = 0.06 assert people != people_dup assert people != people_alt
def test_people_lockability(): """Test the lockability of People objects.""" weekday_office = ScheduleDay( 'Weekday Office Occupancy', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) saturday_office = ScheduleDay( 'Saturday Office Occupancy', [0, 0.25, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) weekend_rule = ScheduleRule(saturday_office) weekend_rule.apply_weekend = True occ_schedule = ScheduleRuleset('Office Occupancy', weekday_office, [weekend_rule], schedule_types.fractional) people = People('Open Office Zone People', 0.05, occ_schedule) people.people_per_area = 0.1 people.lock() with pytest.raises(AttributeError): people.people_per_area = 0.1 with pytest.raises(AttributeError): people.occupancy_schedule.default_day_schedule.remove_value_by_time( Time(17, 0)) people.unlock() people.people_per_area = 0.05 with pytest.raises(AttributeError): people.occupancy_schedule.default_day_schedule.remove_value_by_time( Time(17, 0))
def test_people_setability(): """Test the setting of properties of People.""" simple_office = ScheduleDay( 'Simple Weekday Occupancy', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) occ_schedule = ScheduleRuleset('Office Occupancy', simple_office, None, schedule_types.fractional) constant_ppl = ScheduleRuleset.from_constant_value( 'Constant Occ', 1, schedule_types.fractional) sleeping_act = ScheduleRuleset.from_constant_value( 'Sleeping Activity', 95, schedule_types.activity_level) people = People('Open Office Zone People', 0.05, occ_schedule) people.identifier = 'Office Zone People' assert people.identifier == 'Office Zone People' people.people_per_area = 0.1 assert people.people_per_area == 0.1 assert people.area_per_person == 10 people.area_per_person = 20 assert people.area_per_person == 20 assert people.people_per_area == 0.05 people.occupancy_schedule = constant_ppl assert people.occupancy_schedule == constant_ppl people.activity_schedule = sleeping_act assert people.activity_schedule.schedule_type_limit == schedule_types.activity_level assert people.activity_schedule.values() == [95] * 8760 people.radiant_fraction = 0.4 assert people.radiant_fraction == 0.4 people.latent_fraction = 0.2 assert people.latent_fraction == 0.2
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 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_check_duplicate_schedule_identifiers(): """Test the check_duplicate_schedule_identifiers method.""" room = Room.from_box('TinyHouseZone', 5, 10, 3) room.properties.energy.program_type = office_program room.properties.energy.add_default_ideal_air() south_face = room[3] south_face.apertures_by_ratio(0.4, 0.01) south_face.apertures[0].overhang(0.5, indoor=False) south_face.apertures[0].overhang(0.5, indoor=True) south_face.apertures[0].move_shades(Vector3D(0, 0, -0.5)) fritted_glass_trans = ScheduleRuleset.from_constant_value( 'Fritted Glass', 0.6, schedule_types.fractional) half_occ = ScheduleRuleset.from_constant_value( 'Half Occupied', 0.5, schedule_types.fractional) south_face.apertures[0].outdoor_shades[0].properties.energy.transmittance_schedule = \ fritted_glass_trans room.properties.energy.people = People('Office Occ', 0.05, half_occ) model = Model('TinyHouse', [room]) assert model.properties.energy.check_duplicate_schedule_identifiers(False) half_occ.unlock() half_occ.identifier = 'Fritted Glass' half_occ.lock() assert not model.properties.energy.check_duplicate_schedule_identifiers(False) with pytest.raises(ValueError): model.properties.energy.check_duplicate_schedule_identifiers(True)
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_check_duplicate_schedule_type_limit_names(): """Test the check_duplicate_schedule_type_limit_names method.""" room = Room.from_box('Tiny House Zone', 5, 10, 3) room.properties.energy.program_type = office_program room.properties.energy.hvac = IdealAirSystem() south_face = room[3] south_face.apertures_by_ratio(0.4, 0.01) south_face.apertures[0].overhang(0.5, indoor=False) south_face.apertures[0].overhang(0.5, indoor=True) south_face.apertures[0].move_shades(Vector3D(0, 0, -0.5)) fritted_glass_trans = ScheduleRuleset.from_constant_value( 'Fritted Glass', 0.6, schedule_types.fractional) on_off = ScheduleTypeLimit('On-off', 0, 1, 'Discrete') full_occ = ScheduleRuleset.from_constant_value('Occupied', 1, on_off) south_face.apertures[0].outdoor_shades[0].properties.energy.transmittance_schedule = \ fritted_glass_trans room.properties.energy.people = People('Office Occ', 0.05, full_occ) model = Model('Tiny House', [room]) assert model.properties.energy.check_duplicate_schedule_type_limit_names( False) full_occ.unlock() new_sch_type = ScheduleTypeLimit('Fractional', 0, 1, 'Discrete') full_occ.schedule_type_limit = new_sch_type full_occ.lock() assert not model.properties.energy.check_duplicate_schedule_type_limit_names( False) with pytest.raises(ValueError): model.properties.energy.check_duplicate_schedule_type_limit_names(True)
def test_people_average(): """Test the People.average method.""" weekday_office = ScheduleDay( 'Weekday Office Occupancy', [0, 1, 0.5, 0], [Time(0, 0), Time(9, 0), Time(17, 0), Time(19, 0)]) weekday_lobby = ScheduleDay( 'Weekday Lobby Occupancy', [0.1, 1, 0.1], [Time(0, 0), Time(8, 0), Time(20, 0)]) weekend_office = ScheduleDay('Weekend Office Occupancy', [0]) weekend_lobby = ScheduleDay('Weekend Office Occupancy', [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 Occupancy', weekday_office, [wknd_office_rule], schedule_types.fractional) lobby_schedule = ScheduleRuleset('Lobby Occupancy', weekday_lobby, [wknd_lobby_rule], schedule_types.fractional) lobby_activity = ScheduleRuleset.from_constant_value( 'Lobby Activity Sched', 160, schedule_types.activity_level) office_people = People('Office People', 0.05, office_schedule) lobby_people = People('Lobby People', 0.1, lobby_schedule, lobby_activity, 0.4, 0.2) office_avg = People.average('Office Average People', [office_people, lobby_people]) assert office_avg.people_per_area == pytest.approx(0.075, rel=1e-3) assert office_avg.radiant_fraction == pytest.approx(0.35, rel=1e-3) assert office_avg.latent_fraction == autocalculate week_vals = office_avg.occupancy_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 act_vals = office_avg.activity_schedule.values(end_date=Date(1, 1)) assert act_vals == [140] * 24
def test_people_dict_methods(): """Test the to/from dict methods.""" weekday_office = ScheduleDay( 'Weekday Office Occupancy', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) saturday_office = ScheduleDay( 'Saturday Office Occupancy', [0, 0.25, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) weekend_rule = ScheduleRule(saturday_office) weekend_rule.apply_weekend = True occ_schedule = ScheduleRuleset('Office Occupancy', weekday_office, [weekend_rule], schedule_types.fractional) people = People('Open Office Zone People', 0.05, occ_schedule) ppl_dict = people.to_dict() new_people = People.from_dict(ppl_dict) assert new_people == people assert ppl_dict == new_people.to_dict()
def test_people_init_from_idf(): """Test the initialization of People from_idf.""" weekday_office = ScheduleDay( 'Weekday Office Occupancy', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) saturday_office = ScheduleDay( 'Saturday Office Occupancy', [0, 0.25, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) weekend_rule = ScheduleRule(saturday_office) weekend_rule.apply_weekend = True occ_schedule = ScheduleRuleset('Office Occupancy', weekday_office, [weekend_rule], schedule_types.fractional) people = People('Open Office Zone People', 0.05, occ_schedule) sched_dict = {occ_schedule.identifier: occ_schedule} zone_id = 'Test Zone' idf_str = people.to_idf(zone_id) rebuilt_people, rebuilt_zone_id = People.from_idf(idf_str, sched_dict) assert people == rebuilt_people assert zone_id == rebuilt_zone_id
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
def test_people_init(): """Test the initialization of People 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', simple_office, None, schedule_types.fractional) people = People('Open Office Zone People', 0.05, occ_schedule) str(people) # test the string representation assert people.identifier == 'Open Office Zone People' assert people.people_per_area == 0.05 assert people.area_per_person == 20 assert people.occupancy_schedule.identifier == 'Office Occupancy' assert people.occupancy_schedule.schedule_type_limit == schedule_types.fractional assert people.occupancy_schedule == occ_schedule assert people.activity_schedule.is_constant assert people.activity_schedule.schedule_type_limit == schedule_types.activity_level assert people.activity_schedule.values() == [120] * 8760 assert people.radiant_fraction == 0.3 assert people.latent_fraction == autocalculate
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
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_
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)
# establish variables for the default schedules used across the library # 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)
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)