def test_setpoint_equality(): """Test the equality of Setpoint objects.""" simple_heat = ScheduleDay( 'Simple Weekday HtgSetp', [18, 21, 18], [Time(0, 0), Time(9, 0), Time(17, 0)]) simple_cool = ScheduleDay( 'Simple Weekday ClgSetp', [28, 24, 28], [Time(0, 0), Time(9, 0), Time(17, 0)]) heat_setpt = ScheduleRuleset('Office Heating', simple_heat, None, schedule_types.temperature) cool_setpt = ScheduleRuleset('Office Cooling', simple_cool, None, schedule_types.temperature) heat_setpt_2 = ScheduleRuleset.from_constant_value( 'Office Heating', 21, schedule_types.temperature) cool_setpt_2 = ScheduleRuleset.from_constant_value( 'Office Cooling', 24, schedule_types.temperature) setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt) setpoint_dup = setpoint.duplicate() setpoint_alt = Setpoint('Office Setpoint', heat_setpt_2, cool_setpt_2) assert setpoint is setpoint assert setpoint is not setpoint_dup assert setpoint == setpoint_dup setpoint_dup.humidifying_setpoint = 30 assert setpoint != setpoint_dup assert setpoint != setpoint_alt
def test_setpoint_init_from_idf_humidity(): """Test the initialization of Setpoint from_idf with humidity setpoints.""" simple_heat = ScheduleDay( 'Simple Weekday HtgSetp', [18, 21, 18], [Time(0, 0), Time(9, 0), Time(17, 0)]) simple_cool = ScheduleDay( 'Simple Weekday ClgSetp', [28, 24, 28], [Time(0, 0), Time(9, 0), Time(17, 0)]) heat_setpt = ScheduleRuleset('Office Heating', simple_heat, None, schedule_types.temperature) cool_setpt = ScheduleRuleset('Office Cooling', simple_cool, None, schedule_types.temperature) humid_setpt = ScheduleRuleset.from_constant_value('Office Humid', 30, schedule_types.humidity) dehumid_setpt = ScheduleRuleset.from_constant_value( 'Office Dehumid', 60, schedule_types.humidity) setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt, humid_setpt, dehumid_setpt) sched_dict = { heat_setpt.identifier: heat_setpt, cool_setpt.identifier: cool_setpt, humid_setpt.identifier: humid_setpt, dehumid_setpt.identifier: dehumid_setpt } zone_id = 'Test Zone' idf_str = setpoint.to_idf(zone_id) humid_idf_str = setpoint.to_idf_humidistat(zone_id) rebuilt_setpoint = Setpoint.from_idf(idf_str, sched_dict) rebuilt_setpoint.add_humidity_from_idf(humid_idf_str, sched_dict) assert setpoint == rebuilt_setpoint
def test_dict_to_object_load(): """Test the dict_to_object method with Setpoint objects.""" heat_setpt = ScheduleRuleset.from_constant_value( 'Office Heating', 21, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Office Cooling', 24, schedule_types.temperature) setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt) setpoint_dict = setpoint.to_dict() new_setpoint = dict_to_object(setpoint_dict) assert isinstance(new_setpoint, Setpoint)
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_ideal_air_init_from_idf(): """Test the initialization of IdealAirSystem from_idf.""" ideal_air = IdealAirSystem('Test_System') with pytest.raises(AssertionError): ideal_air.to_idf() zone_id = 'ShoeBox' room = Room.from_box(zone_id, 5, 10, 3, 90, Point3D(0, 0, 3)) room.properties.energy.add_default_ideal_air() ideal_air = room.properties.energy.hvac with pytest.raises(AssertionError): ideal_air.to_idf() heat_setpt = ScheduleRuleset.from_constant_value( 'Office Heating', 21, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Office Cooling', 24, schedule_types.temperature) setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt) room.properties.energy.setpoint = setpoint idf_str = ideal_air.to_idf() schedule_dict = {} rebuilt_ideal_air, rebuilt_zone_id = IdealAirSystem.from_idf( idf_str, schedule_dict) assert ideal_air == rebuilt_ideal_air assert zone_id == rebuilt_zone_id
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 model_energy_window_ventilation(directory): room = Room.from_box('TinyHouseZone', 5, 10, 3) room.properties.energy.add_default_ideal_air() south_face = room[3] north_face = room[1] south_face.apertures_by_ratio(0.4, 0.01) north_face.apertures_by_ratio(0.4, 0.01) south_face.apertures[0].is_operable = True north_face.apertures[0].is_operable = True heat_setpt = ScheduleRuleset.from_constant_value( 'House Heating', 20, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'House Cooling', 28, schedule_types.temperature) setpoint = Setpoint('House Setpoint', heat_setpt, cool_setpt) room.properties.energy.setpoint = setpoint vent_control = VentilationControl(22, 27, 12, 30) room.properties.energy.window_vent_control = vent_control ventilation = VentilationOpening(wind_cross_vent=True) room.properties.energy.assign_ventilation_opening(ventilation) model = Model('TinyHouse', [room]) dest_file = os.path.join(directory, 'model_energy_window_ventilation.json') with open(dest_file, 'w') as fp: json.dump(model.to_dict(included_prop=['energy']), fp, indent=4)
def test_setpoint_lockability(): """Test the lockability of Setpoint objects.""" heat_setpt = ScheduleRuleset.from_constant_value( 'Office Heating', 21, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Office Cooling', 24, schedule_types.temperature) setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt) setpoint.heating_setpoint = 20 setpoint.lock() with pytest.raises(AttributeError): setpoint.heating_setpoint = 22 setpoint.unlock() setpoint.heating_setpoint = 22
def test_setpoint_init_from_idf(): """Test the initialization of Setpoint from_idf.""" simple_heat = ScheduleDay( 'Simple Weekday HtgSetp', [18, 21, 18], [Time(0, 0), Time(9, 0), Time(17, 0)]) simple_cool = ScheduleDay( 'Simple Weekday ClgSetp', [28, 24, 28], [Time(0, 0), Time(9, 0), Time(17, 0)]) heat_setpt = ScheduleRuleset('Office Heating', simple_heat, None, schedule_types.temperature) cool_setpt = ScheduleRuleset('Office Cooling', simple_cool, None, schedule_types.temperature) setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt) sched_dict = {heat_setpt.name: heat_setpt, cool_setpt.name: cool_setpt} idf_str = setpoint.to_idf() rebuilt_setpoint = Setpoint.from_idf(idf_str, sched_dict) assert setpoint == rebuilt_setpoint
def test_run_idf_window_ventilation(): """Test the Model.to.idf and run_idf method with a model possessing operable windows.""" room = Room.from_box('TinyHouseZone', 5, 10, 3) room.properties.energy.add_default_ideal_air() south_face = room[3] north_face = room[1] south_face.apertures_by_ratio(0.4, 0.01) north_face.apertures_by_ratio(0.4, 0.01) south_face.apertures[0].is_operable = True north_face.apertures[0].is_operable = True heat_setpt = ScheduleRuleset.from_constant_value( 'House Heating', 20, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'House Cooling', 28, schedule_types.temperature) setpoint = Setpoint('House Setpoint', heat_setpt, cool_setpt) room.properties.energy.setpoint = setpoint vent_control = VentilationControl(22, 27, 12, 30) room.properties.energy.window_vent_control = vent_control ventilation = VentilationOpening(wind_cross_vent=True) op_aps = room.properties.energy.assign_ventilation_opening(ventilation) assert len(op_aps) == 2 model = Model('TinyHouse', [room]) # Get the input SimulationParameter sim_par = SimulationParameter() sim_par.output.add_zone_energy_use() ddy_file = './tests/ddy/chicago.ddy' sim_par.sizing_parameter.add_from_ddy_996_004(ddy_file) sim_par.run_period.end_date = Date(6, 7) sim_par.run_period.start_date = Date(6, 1) # create the IDF string for simulation paramters and model idf_str = '\n\n'.join((sim_par.to_idf(), model.to.idf(model))) # write the final string into an IDF idf = os.path.join(folders.default_simulation_folder, 'test_file_window_vent', 'in.idf') write_to_file(idf, idf_str, True) # prepare the IDF for simulation epw_file = './tests/simulation/chicago.epw' prepare_idf_for_simulation(idf, epw_file) # run the IDF through EnergyPlus sql, zsz, rdd, html, err = run_idf(idf, epw_file) assert os.path.isfile(sql) assert os.path.isfile(err) err_obj = Err(err) assert 'EnergyPlus Completed Successfully' in err_obj.file_contents
def test_setpoint_average(): """Test the Setpoint.average method.""" heat_setpt = ScheduleRuleset.from_constant_value( 'Office Heating', 22, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Office Cooling', 24, schedule_types.temperature) office_setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt) lobby_setpoint = office_setpoint.duplicate() lobby_setpoint.identifier = 'Lobby Setpoint' lobby_setpoint.heating_setpoint = 18 lobby_setpoint.cooling_setpoint = 28 office_avg = Setpoint.average('Office Average Setpoint', [office_setpoint, lobby_setpoint]) assert office_avg.heating_setpoint == pytest.approx(20, rel=1e-3) assert office_avg.heating_setback == pytest.approx(20, rel=1e-3) assert office_avg.cooling_setpoint == pytest.approx(26, rel=1e-3) assert office_avg.cooling_setback == pytest.approx(26, rel=1e-3) assert office_avg.humidifying_setpoint is None assert office_avg.humidifying_setback is None assert office_avg.dehumidifying_setpoint is None assert office_avg.dehumidifying_setback is None
def test_setpoint_dict_methods(): """Test the to/from dict methods.""" simple_heat = ScheduleDay( 'Simple Weekday HtgSetp', [18, 21, 18], [Time(0, 0), Time(9, 0), Time(17, 0)]) simple_cool = ScheduleDay( 'Simple Weekday ClgSetp', [28, 24, 28], [Time(0, 0), Time(9, 0), Time(17, 0)]) heat_setpt = ScheduleRuleset('Office Heating', simple_heat, None, schedule_types.temperature) cool_setpt = ScheduleRuleset('Office Cooling', simple_cool, None, schedule_types.temperature) humid_setpt = ScheduleRuleset.from_constant_value('Office Humid', 30, schedule_types.humidity) dehumid_setpt = ScheduleRuleset.from_constant_value( 'Office Dehumid', 60, schedule_types.humidity) setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt, humid_setpt, dehumid_setpt) setp_dict = setpoint.to_dict() new_setpoint = Setpoint.from_dict(setp_dict) assert new_setpoint == setpoint assert setp_dict == new_setpoint.to_dict()
def test_setpoint_init_humidity(): """Test the initialization of Setpoint with humidity setpoints.""" heat_setpt = ScheduleRuleset.from_constant_value( 'Office Heating', 21, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Office Cooling', 24, schedule_types.temperature) setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt) setpoint.humidifying_setpoint = 30 setpoint.dehumidifying_setpoint = 60 str(setpoint) # test the string representation assert setpoint.identifier == 'Office Setpoint' assert setpoint.heating_schedule == heat_setpt assert setpoint.heating_setpoint == 21 assert setpoint.heating_setback == 21 assert setpoint.cooling_schedule == cool_setpt assert setpoint.cooling_setpoint == 24 assert setpoint.cooling_setback == 24 assert setpoint.humidifying_schedule.is_constant assert setpoint.humidifying_setpoint == 30 assert setpoint.humidifying_setback == 30 assert setpoint.dehumidifying_schedule.is_constant assert setpoint.dehumidifying_setpoint == 60 assert setpoint.dehumidifying_setback == 60
def dup_setpoint(hb_obj): """Duplicate a setpoint object assigned to a Room or ProgramType.""" # try to get the setpoint object assgined to the Room or ProgramType try: # assume it's a Room setpt_obj = hb_obj.properties.energy.setpoint except AttributeError: # it's a ProgramType setpt_obj = hb_obj.setpoint try: # duplicate the setpoint object return setpt_obj.duplicate() except AttributeError: # create a new object if it does not exist heat_sch = ScheduleRuleset.from_constant_value( '{}_HtgSetp'.format(hb_obj.identifier), -50, _type_lib.temperature) cool_sch = ScheduleRuleset.from_constant_value( '{}_ClgSetp'.format(hb_obj.identifier), 50, _type_lib.temperature) return Setpoint('{}_Setpoint'.format(hb_obj.identifier), heat_sch, cool_sch)
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_setpoint_init_with_setback(): """Test the initialization of Setpoint with a setback schedule.""" simple_heat = ScheduleDay( 'Simple Weekday HtgSetp', [18, 21, 18], [Time(0, 0), Time(9, 0), Time(17, 0)]) simple_cool = ScheduleDay( 'Simple Weekday ClgSetp', [28, 24, 28], [Time(0, 0), Time(9, 0), Time(17, 0)]) heat_setpt = ScheduleRuleset('Office Heating', simple_heat, None, schedule_types.temperature) cool_setpt = ScheduleRuleset('Office Cooling', simple_cool, None, schedule_types.temperature) setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt) assert setpoint.identifier == 'Office Setpoint' assert setpoint.heating_schedule == heat_setpt assert setpoint.heating_setpoint == 21 assert setpoint.heating_setback == 18 assert setpoint.cooling_schedule == cool_setpt assert setpoint.cooling_setpoint == 24 assert setpoint.cooling_setback == 28
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_setpoint_init(): """Test the initialization of Setpoint and basic properties.""" heat_setpt = ScheduleRuleset.from_constant_value( 'Office Heating', 21, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Office Cooling', 24, schedule_types.temperature) setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt) str(setpoint) # test the string representation assert setpoint.identifier == 'Office Setpoint' assert setpoint.heating_schedule == heat_setpt assert setpoint.heating_setpoint == 21 assert setpoint.heating_setback == 21 assert setpoint.cooling_schedule == cool_setpt assert setpoint.cooling_setpoint == 24 assert setpoint.cooling_setback == 24 assert setpoint.humidifying_schedule is None assert setpoint.humidifying_setpoint is None assert setpoint.humidifying_setback is None assert setpoint.dehumidifying_schedule is None assert setpoint.dehumidifying_setpoint is None assert setpoint.dehumidifying_setback is None
def test_setpoint_setability(): """Test the setting of properties of Setpoint.""" heat_setpt = ScheduleRuleset.from_constant_value( 'Office Heating', 21, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Office Cooling', 24, schedule_types.temperature) setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt) setpoint.identifier = 'Office Zone Setpoint' assert setpoint.identifier == 'Office Zone Setpoint' setpoint.heating_setpoint = 20 assert setpoint.heating_setpoint == 20 assert setpoint.heating_setback == 20 setpoint.cooling_setpoint = 26 assert setpoint.cooling_setpoint == 26 assert setpoint.cooling_setback == 26 setpoint.humidifying_setpoint = 30 assert setpoint.humidifying_setpoint == 30 assert setpoint.humidifying_setback == 30 setpoint.dehumidifying_setpoint = 60 assert setpoint.dehumidifying_setpoint == 60 assert setpoint.dehumidifying_setback == 60
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)
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 _json_program_types['Generic Office Program'] = office_program # make lists of program types to look up items in the library PROGRAM_TYPES = tuple(_json_program_types.keys()) def program_type_by_name(program_type_name): """Get a program_type from the library given its name.
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)
def processItem(item): tpBuilding = item[0] tpShadingFacesCluster = item[1] buildingName = item[2] defaultProgramIdentifier = item[3] defaultConstructionSetIdentifier = item[4] coolingSetpoint = item[5] heatingSetpoint = item[6] humidifyingSetpoint = item[7] dehumidifyingSetpoint = item[8] roomNameKey = item[9] roomTypeKey = item[10] if buildingName: buildingName = buildingName.replace(" ","_") else: buildingName = "GENERICBUILDING" rooms = [] tpCells = [] _ = tpBuilding.Cells(None, tpCells) # Sort cells by Z Levels tpCells.sort(key=lambda c: cellFloor(c), reverse=False) fl = floorLevels(tpCells, 2) spaceNames = [] for spaceNumber, tpCell in enumerate(tpCells): tpDictionary = tpCell.GetDictionary() tpCellName = None tpCellStory = None tpCellProgramIdentifier = None tpCellConstructionSetIdentifier = None tpCellConditioned = True if tpDictionary: keyName = getKeyName(tpDictionary, 'Story') tpCellStory = DictionaryValueAtKey.processItem(tpDictionary, keyName) if tpCellStory: tpCellStory = tpCellStory.replace(" ","_") else: tpCellStory = fl[spaceNumber] if roomNameKey: keyName = getKeyName(tpDictionary, roomNameKey) else: keyName = getKeyName(tpDictionary, 'Name') tpCellName = DictionaryValueAtKey.processItem(tpDictionary,keyName) if tpCellName: tpCellName = createUniqueName(tpCellName.replace(" ","_"), spaceNames, 1) else: tpCellName = tpCellStory+"_SPACE_"+(str(spaceNumber+1)) if roomTypeKey: keyName = getKeyName(tpDictionary, roomTypeKey) else: keyName = getKeyName(tpDictionary, 'Program') tpCellProgramIdentifier = DictionaryValueAtKey.processItem(tpDictionary, keyName) if tpCellProgramIdentifier: program = prog_type_lib.program_type_by_identifier(tpCellProgramIdentifier) elif defaultProgramIdentifier: program = prog_type_lib.program_type_by_identifier(defaultProgramIdentifier) else: program = prog_type_lib.office_program #Default Office Program as a last resort keyName = getKeyName(tpDictionary, 'construction_set') tpCellConstructionSetIdentifier = DictionaryValueAtKey.processItem(tpDictionary, keyName) if tpCellConstructionSetIdentifier: constr_set = constr_set_lib.construction_set_by_identifier(tpCellConstructionSetIdentifier) elif defaultConstructionSetIdentifier: constr_set = constr_set_lib.construction_set_by_identifier(defaultConstructionSetIdentifier) else: constr_set = constr_set_lib.construction_set_by_identifier("Default Generic Construction Set") else: tpCellStory = fl[spaceNumber] tpCellName = tpCellStory+"_SPACE_"+(str(spaceNumber+1)) program = prog_type_lib.office_program constr_set = constr_set_lib.construction_set_by_identifier("Default Generic Construction Set") spaceNames.append(tpCellName) tpCellFaces = [] _ = tpCell.Faces(None, tpCellFaces) if tpCellFaces: hbRoomFaces = [] for tpFaceNumber, tpCellFace in enumerate(tpCellFaces): tpCellFaceNormal = topologic.FaceUtility.NormalAtParameters(tpCellFace, 0.5, 0.5) hbRoomFacePoints = [] tpFaceVertices = [] _ = tpCellFace.ExternalBoundary().Vertices(None, tpFaceVertices) for tpVertex in tpFaceVertices: hbRoomFacePoints.append(Point3D(tpVertex.X(), tpVertex.Y(), tpVertex.Z())) hbRoomFace = Face(tpCellName+'_Face_'+str(tpFaceNumber+1), Face3D(hbRoomFacePoints)) tpFaceApertures = [] _ = tpCellFace.Apertures(tpFaceApertures) if tpFaceApertures: for tpFaceApertureNumber, tpFaceAperture in enumerate(tpFaceApertures): apertureTopology = topologic.Aperture.Topology(tpFaceAperture) tpFaceApertureDictionary = apertureTopology.GetDictionary() if tpFaceApertureDictionary: tpFaceApertureType = DictionaryValueAtKey.processItem(tpFaceApertureDictionary,'type') hbFaceAperturePoints = [] tpFaceApertureVertices = [] _ = apertureTopology.ExternalBoundary().Vertices(None, tpFaceApertureVertices) for tpFaceApertureVertex in tpFaceApertureVertices: hbFaceAperturePoints.append(Point3D(tpFaceApertureVertex.X(), tpFaceApertureVertex.Y(), tpFaceApertureVertex.Z())) if(tpFaceApertureType): if ("door" in tpFaceApertureType.lower()): hbFaceAperture = Door(tpCellName+'_Face_'+str(tpFaceNumber+1)+'_Door_'+str(tpFaceApertureNumber), Face3D(hbFaceAperturePoints)) else: hbFaceAperture = Aperture(tpCellName+'_Face_'+str(tpFaceNumber+1)+'_Window_'+str(tpFaceApertureNumber), Face3D(hbFaceAperturePoints)) else: hbFaceAperture = Aperture(tpCellName+'_Face_'+str(tpFaceNumber+1)+'_Window_'+str(tpFaceApertureNumber), Face3D(hbFaceAperturePoints)) hbRoomFace.add_aperture(hbFaceAperture) else: tpFaceDictionary = tpCellFace.GetDictionary() if (abs(tpCellFaceNormal[2]) < 1e-6) and tpFaceDictionary: #It is a mostly vertical wall and has a dictionary apertureRatio = DictionaryValueAtKey.processItem(tpFaceDictionary,'apertureRatio') if apertureRatio: hbRoomFace.apertures_by_ratio(apertureRatio, tolerance=0.01) fType = honeybee.facetype.get_type_from_normal(Vector3D(tpCellFaceNormal[0],tpCellFaceNormal[1],tpCellFaceNormal[2]), roof_angle=30, floor_angle=150) hbRoomFace.type = fType hbRoomFaces.append(hbRoomFace) room = Room(tpCellName, hbRoomFaces, 0.01, 1) heat_setpt = ScheduleRuleset.from_constant_value('Room Heating', heatingSetpoint, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value('Room Cooling', coolingSetpoint, schedule_types.temperature) humidify_setpt = ScheduleRuleset.from_constant_value('Room Humidifying', humidifyingSetpoint, schedule_types.humidity) dehumidify_setpt = ScheduleRuleset.from_constant_value('Room Dehumidifying', dehumidifyingSetpoint, schedule_types.humidity) setpoint = Setpoint('Room Setpoint', heat_setpt, cool_setpt, humidify_setpt, dehumidify_setpt) simple_office = ScheduleDay('Simple Weekday', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) #Todo: Remove hardwired scheduleday schedule = ScheduleRuleset('Office Water Use', simple_office, None, schedule_types.fractional) #Todo: Remove hardwired schedule shw = ServiceHotWater('Office Hot Water', 0.1, schedule) #Todo: Remove hardwired schedule hot water room.properties.energy.program_type = program room.properties.energy.construction_set = constr_set room.properties.energy.add_default_ideal_air() #Ideal Air Exchange room.properties.energy.setpoint = setpoint #Heating/Cooling/Humidifying/Dehumidifying room.properties.energy.service_hot_water = shw #Service Hot Water if tpCellStory: room.story = tpCellStory rooms.append(room) Room.solve_adjacency(rooms, 0.01) #for room in rooms: #room.properties.energy.construction_set = constr_set #Room.stories_by_floor_height(rooms, min_difference=2.0) if(tpShadingFacesCluster): hbShades = [] tpShadingFaces = [] _ = tpShadingFacesCluster.Faces(None, tpShadingFaces) for faceIndex, tpShadingFace in enumerate(tpShadingFaces): faceVertices = [] _ = tpShadingFace.ExternalBoundary().Vertices(None, faceVertices) facePoints = [] for aVertex in faceVertices: facePoints.append(Point3D(aVertex.X(), aVertex.Y(), aVertex.Z())) hbShadingFace = Face3D(facePoints, None, []) hbShade = Shade("SHADINGSURFACE_" + str(faceIndex+1), hbShadingFace) hbShades.append(hbShade) model = Model(buildingName, rooms, orphaned_shades=hbShades) return model
def processItem(item): osModel = item[0] weatherFilePath = item[1] designDayFilePath = item[2] tpBuilding = item[3] tpShadingSurfacesCluster = item[4] floorLevels = item[5] buildingName = item[6] buildingType = item[7] defaultSpaceType = item[8] northAxis = item[9] glazingRatio = item[10] coolingTemp = item[11] heatingTemp = item[12] rooms = [] tpCells = [] _ = tpBuilding.Cells(None, tpCells) # Sort cells by Z Levels tpCells.sort(key=lambda c: c.CenterOfMass().Z(), reverse=False) for spaceNumber, tpCell in enumerate(tpCells): tpDictionary = tpCell.GetDictionary() tpCellName = None tpCellStory = None if tpDictionary: tpCellName = valueAtKey(tpDictionary, 'name') tpCellStory = valueAtKey(tpDictionary, 'story') tpCellFaces = [] _ = tpCell.Faces(None, tpCellFaces) if tpCellFaces: hbRoomFaces = [] for tpFaceNumber, tpCellFace in enumerate(tpCellFaces): hbRoomFacePoints = [] tpFaceVertices = [] _ = tpCellFace.ExternalBoundary().Vertices( None, tpFaceVertices) for tpVertex in tpFaceVertices: hbRoomFacePoints.append( Point3D(tpVertex.X(), tpVertex.Y(), tpVertex.Z())) hbRoomFace = Face( tpCellName + '_Face_' + str(tpFaceNumber + 1), Face3D(hbRoomFacePoints)) faceNormal = topologic.FaceUtility.NormalAtParameters( tpFace, 0.5, 0.5) ang = math.degrees(math.acos(faceNormal.dot([0, 0, 1]))) print("HBJSONByTopology: Angle between face normal and UP", ang) if ang > 175: hbRoomFace.type = "floor" tpFaceApertures = [] _ = tpCellFace.Apertures(tpFaceApertures) if tpFaceApertures: for tpFaceApertureNumber, tpFaceAperture in enumerate( tpFaceApertures): apertureTopology = topologic.Aperture.Topology( tpFaceAperture) tpFaceApertureDictionary = apertureTopology.GetDictionary( ) if tpFaceApertureDictionary: tpFaceApertureType = valueAtKey( tpFaceApertureDictionary, 'type') hbFaceAperturePoints = [] tpFaceApertureVertices = [] _ = apertureTopology.ExternalBoundary().Vertices( None, tpFaceApertureVertices) for tpFaceApertureVertex in tpFaceApertureVertices: hbFaceAperturePoints.append( Point3D(tpFaceApertureVertex.X(), tpFaceApertureVertex.Y(), tpFaceApertureVertex.Z())) if (tpFaceApertureType): if ("door" in tpFaceApertureType.lower()): hbFaceAperture = Door( tpCellName + '_Face_' + str(tpFaceNumber + 1) + '_Door_' + str(tpFaceApertureNumber), Face3D(hbFaceAperturePoints)) else: hbFaceAperture = Aperture( tpCellName + '_Face_' + str(tpFaceNumber + 1) + '_Window_' + str(tpFaceApertureNumber), Face3D(hbFaceAperturePoints)) else: hbFaceAperture = Aperture( tpCellName + '_Face_' + str(tpFaceNumber + 1) + '_Window_' + str(tpFaceApertureNumber), Face3D(hbFaceAperturePoints)) hbRoomFace.add_aperture(hbFaceAperture) hbRoomFaces.append(hbRoomFace) if tpCellName == None: tpCellName = "GENERICROOM_" + (str(spaceNumber + 1)) room = Room(tpCellName, hbRoomFaces, 0.01, 1) #ToDo: Figure out how to add Story number heat_setpt = ScheduleRuleset.from_constant_value( 'Room Heating', heatingTemp, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'Room Cooling', coolingTemp, schedule_types.temperature) humidify_setpt = ScheduleRuleset.from_constant_value( 'Room Humidifying', 30, schedule_types.humidity) #Todo: Remove hardwired number dehumidify_setpt = ScheduleRuleset.from_constant_value( 'Room Dehumidifying', 55, schedule_types.humidity) #Todo: Remove hardwired number setpoint = Setpoint('Room Setpoint', heat_setpt, cool_setpt, humidify_setpt, dehumidify_setpt) simple_office = ScheduleDay( 'Simple Weekday', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) schedule = ScheduleRuleset('Office Water Use', simple_office, None, schedule_types.fractional) shw = ServiceHotWater('Office Hot Water', 0.1, schedule) room.properties.energy.program_type = prog_type_lib.office_program #Default Office Program room.properties.energy.add_default_ideal_air() #Ideal Air Exchange room.properties.energy.setpoint = setpoint #Heating/Cooling/Humidifying/Dehumidifying room.properties.energy.service_hot_water = shw #Service Hot Water if tpCellStory: room.story = tpCellStory rooms.append(room) Room.solve_adjacency(rooms, 0.01) Room.stories_by_floor_height(rooms, min_difference=2.0) hbShades = [] shadingFaces = [] _ = tpShadingSurfacesCluster.Faces(None, shadingFaces) for faceIndex, shadingFace in enumerate(shadingFaces): faceVertices = [] _ = shadingFace.ExternalBoundary().Vertices(None, faceVertices) facePoints = [] for aVertex in faceVertices: facePoints.append(Point3D(aVertex.X(), aVertex.Y(), aVertex.Z())) hbShadingFace = Face3D(facePoints, None, []) hbShade = Shade("SHADINGSURFACE_" + str(faceIndex), hbShadingFace) hbShades.append(hbShade) model = Model('TopologicModel', rooms, orphaned_shades=hbShades) return model.to_dict()
def model_energy_afn_multizone(directory): # south Room szone_pts = Face3D( [Point3D(0, 0), Point3D(20, 0), Point3D(20, 10), Point3D(0, 10)]) sroom = Room.from_polyface3d('SouthRoom', Polyface3D.from_offset_face(szone_pts, 3)) # north Room nzone_pts = Face3D( [Point3D(0, 10), Point3D(20, 10), Point3D(20, 20), Point3D(0, 20)]) nroom = Room.from_polyface3d('NorthRoom', Polyface3D.from_offset_face(nzone_pts, 3)) # add exterior windows on east/west faces sroom[2].apertures_by_ratio(0.3) nroom[4].apertures_by_ratio(0.3) sroom[2].apertures[0].is_operable = True nroom[4].apertures[0].is_operable = True # add small interior windows on north/south faces sroom[3].apertures_by_ratio(0.15) nroom[1].apertures_by_ratio(0.15) sroom[3].apertures[0].is_operable = True nroom[1].apertures[0].is_operable = True # ventilation openings vent_openings = VentilationOpening(fraction_area_operable=1, fraction_height_operable=1, discharge_coefficient=0.6, wind_cross_vent=False, flow_coefficient_closed=0.001, flow_exponent_closed=0.667, two_way_threshold=0.0001) sroom.properties.energy.assign_ventilation_opening(vent_openings) nroom.properties.energy.assign_ventilation_opening( vent_openings.duplicate()) # make ventilation control heat_setpt = ScheduleRuleset.from_constant_value( 'House Heating', 20, schedule_types.temperature) cool_setpt = ScheduleRuleset.from_constant_value( 'House Cooling', 28, schedule_types.temperature) setpoint = Setpoint('House Setpoint', heat_setpt, cool_setpt) sroom.properties.energy.setpoint = setpoint nroom.properties.energy.setpoint = setpoint.duplicate() vent_control = VentilationControl(22, 27, 12, 30) sroom.properties.energy.window_vent_control = vent_control nroom.properties.energy.window_vent_control = vent_control.duplicate() # rooms rooms = [sroom, nroom] for room in rooms: # Add program and hvac room.properties.energy.program_type = prog_type_lib.office_program # make model model = Model('Two_Zone_Simple', rooms) vsc = VentilationSimulationControl( vent_control_type='MultiZoneWithoutDistribution', building_type='LowRise', long_axis_angle=0, aspect_ratio=1) model.properties.energy.ventilation_simulation_control = vsc # make interior faces Room.solve_adjacency(rooms, 0.01) # make afn afn.generate(model.rooms) dest_file = os.path.join(directory, 'model_energy_afn.json') with open(dest_file, 'w') as fp: json.dump(model.to_dict(included_prop=['energy']), fp, indent=4)
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_