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 test_ideal_air_system_equality(): """Test the equality of IdealAirSystem objects.""" ideal_air = IdealAirSystem('Test System') ideal_air_dup = ideal_air.duplicate() ideal_air_alt = IdealAirSystem('Test System', sensible_heat_recovery=0.75, latent_heat_recovery=0.6) assert ideal_air is ideal_air assert ideal_air is not ideal_air_dup assert ideal_air == ideal_air_dup ideal_air_dup.sensible_heat_recovery = 0.6 assert ideal_air != ideal_air_dup assert ideal_air != ideal_air_alt
def test_set_all_room_2d_hvac(): """Test the set_all_room_2d_hvac method on a Building.""" 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)) pts_3 = (Point3D(0, 10, 3), Point3D(0, 20, 3), Point3D(10, 20, 3), Point3D(10, 10, 3)) pts_4 = (Point3D(10, 10, 3), Point3D(10, 20, 3), Point3D(20, 20, 3), Point3D(20, 10, 3)) room2d_1 = Room2D('Office1', Face3D(pts_1), 3) room2d_2 = Room2D('Office2', Face3D(pts_2), 3) room2d_3 = Room2D('Office3', Face3D(pts_3), 3) room2d_4 = Room2D('Office4', Face3D(pts_4), 3) story = Story('OfficeFloor', [room2d_1, room2d_2, room2d_3, room2d_4]) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.multiplier = 4 building = Building('OfficeBuilding', [story]) sensible = 0.8 latent = 0.7 ideal_air_sys = IdealAirSystem('Office Ideal Air', sensible_heat_recovery=sensible, latent_heat_recovery=latent) building.properties.energy.set_all_room_2d_hvac(ideal_air_sys, False) assert all(isinstance(room.properties.energy.hvac, IdealAirSystem) for room in building.unique_room_2ds) assert all(room.properties.energy.hvac.sensible_heat_recovery == sensible for room in building.unique_room_2ds) assert all(room.properties.energy.hvac.latent_heat_recovery == latent for room in building.unique_room_2ds)
def _hvac_from_long_name(self, hvac_long_name, vintage='ASHRAE_2013'): """Get an HVAC class instance from it's long name (as found in a geoJSON).""" hvac_reg = None if BuildingEnergyProperties._HVAC_REGISTRY is None: ext_folder = [ f for f in folders.standards_extension_folders if f.endswith('honeybee_energy_standards') ] if len(ext_folder) == 1: hvac_reg = os.path.join(ext_folder[0], 'hvac_registry.json') if os.path.isfile(hvac_reg): with open(hvac_reg, 'r') as f: BuildingEnergyProperties._HVAC_REGISTRY = json.load(f) BuildingEnergyProperties._HVAC_REGISTRY['Ideal Air System'] = \ 'IdealAirSystem' hvac_reg = BuildingEnergyProperties._HVAC_REGISTRY if hvac_reg is not None: try: hvac_class = self._HVAC_TYPES_DICT[hvac_reg[hvac_long_name]] except KeyError: # HVAC type is not in the library return None if hvac_class is IdealAirSystem: return IdealAirSystem('{} {}'.format(self.host.identifier, 'Ideal Air')) else: # assume it is an HVAC template hvac_id = '{} {}'.format(self.host.identifier, hvac_reg[hvac_long_name]) return hvac_class(hvac_id, vintage, hvac_reg[hvac_long_name])
def add_default_ideal_air(self): """Add a default IdealAirSystem to this Room2D. The identifier of this system will be derived from the room identifier and will align with the naming convention that EnergyPlus uses for templates Ideal Air systems. """ hvac_id = '{} Ideal Loads Air System'.format(self.host.identifier) self.hvac = IdealAirSystem(hvac_id)
def test_ideal_air_system_init(): """Test the initialization of IdealAirSystem and basic properties.""" ideal_air = IdealAirSystem('Test System') str(ideal_air) # test the string representation assert ideal_air.identifier == 'Test System' assert ideal_air.economizer_type == 'DifferentialDryBulb' assert not ideal_air.demand_controlled_ventilation assert ideal_air.sensible_heat_recovery == 0 assert ideal_air.latent_heat_recovery == 0 assert ideal_air.heating_air_temperature == 50 assert ideal_air.cooling_air_temperature == 13 assert ideal_air.heating_limit == autosize assert ideal_air.cooling_limit == autosize assert ideal_air.heating_availability is None assert ideal_air.cooling_availability is None
def test_single_room(): """Test that each IdealAirSystem can be assigned to only one Room.""" first_floor = Room.from_box('First_Floor', 10, 10, 3, origin=Point3D(0, 0, 0)) second_floor = Room.from_box('Second_Floor', 10, 10, 3, origin=Point3D(0, 0, 3)) ideal_air = IdealAirSystem('Test_System') first_floor.properties.energy.hvac = ideal_air with pytest.raises(ValueError): second_floor.properties.energy.hvac = ideal_air
def test_set_ideal_air(): """Test the setting of a IdealAirSystems on a Room2D.""" pts = (Point3D(0, 0, 3), Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(0, 10, 3)) ashrae_base = SimpleWindowRatio(0.4) room = Room2D('SquareShoebox', Face3D(pts), 3) room.set_outdoor_window_parameters(ashrae_base) sensible = 0.8 latent = 0.7 ideal_air_sys = IdealAirSystem('Test HVAC', sensible_heat_recovery=sensible, latent_heat_recovery=latent) room.properties.energy.hvac = ideal_air_sys assert room.properties.energy.hvac == ideal_air_sys assert room.properties.energy.hvac.sensible_heat_recovery == sensible assert room.properties.energy.hvac.latent_heat_recovery == latent hb_room, adj = room.to_honeybee() assert hb_room.properties.energy.hvac == ideal_air_sys assert hb_room.properties.energy.hvac.sensible_heat_recovery == sensible assert hb_room.properties.energy.hvac.latent_heat_recovery == latent
def ideal_air_detailed(directory): ideal_air = IdealAirSystem('Passive House HVAC System') ideal_air.economizer_type = 'DifferentialEnthalpy' ideal_air.demand_controlled_ventilation = True ideal_air.sensible_heat_recovery = 0.75 ideal_air.latent_heat_recovery = 0.6 ideal_air.heating_air_temperature = 40 ideal_air.cooling_air_temperature = 15 ideal_air.heating_limit = 2000 ideal_air.cooling_limit = 3500 sch_day = ScheduleDay( 'Day Control', [0, 1, 0], [Time(0, 0), Time(8, 0), Time(22, 0)]) schedule = ScheduleRuleset('HVAC Control', sch_day, None, schedule_types.on_off) ideal_air.heating_availability = schedule ideal_air.cooling_availability = schedule dest_file = os.path.join(directory, 'ideal_air_detailed.json') with open(dest_file, 'w') as fp: json.dump(ideal_air.to_dict(abridged=True), fp, indent=4)
def ideal_air_default(directory): ideal_air = IdealAirSystem('Default HVAC System') dest_file = os.path.join(directory, 'ideal_air_default.json') with open(dest_file, 'w') as fp: json.dump(ideal_air.to_dict(abridged=True), fp, indent=4)
def test_ideal_air_system_setability(): """Test the setting of properties of IdealAirSystem.""" ideal_air = IdealAirSystem('Test System') ideal_air.identifier = 'Test System2' assert ideal_air.identifier == 'Test System2' ideal_air.economizer_type = 'DifferentialEnthalpy' assert ideal_air.economizer_type == 'DifferentialEnthalpy' ideal_air.sensible_heat_recovery = 0.75 assert ideal_air.sensible_heat_recovery == 0.75 ideal_air.latent_heat_recovery = 0.65 assert ideal_air.latent_heat_recovery == 0.65 ideal_air.heating_air_temperature = 40 assert ideal_air.heating_air_temperature == 40 ideal_air.cooling_air_temperature = 15 assert ideal_air.cooling_air_temperature == 15 ideal_air.heating_limit = 1000 assert ideal_air.heating_limit == 1000 ideal_air.cooling_limit = 2000 assert ideal_air.cooling_limit == 2000 sch_day = ScheduleDay( 'Day Control', [0, 1, 0], [Time(0, 0), Time(8, 0), Time(22, 0)]) schedule = ScheduleRuleset('HVAC Control', sch_day, None, schedule_types.on_off) ideal_air.heating_availability = schedule assert ideal_air.heating_availability == schedule ideal_air.cooling_availability = schedule assert ideal_air.cooling_availability == schedule
def test_ideal_air_dict_methods(): """Test the to/from dict methods.""" ideal_air = IdealAirSystem('Passive House HVAC System') ideal_air.economizer_type = 'DifferentialEnthalpy' ideal_air.demand_controlled_ventilation = True ideal_air.sensible_heat_recovery = 0.75 ideal_air.latent_heat_recovery = 0.6 ideal_air.heating_air_temperature = 40 ideal_air.cooling_air_temperature = 15 ideal_air.heating_limit = 2000 ideal_air.cooling_limit = 3500 sch_day = ScheduleDay( 'Day Control', [0, 1, 0], [Time(0, 0), Time(8, 0), Time(22, 0)]) schedule = ScheduleRuleset('HVAC Control', sch_day, None, schedule_types.on_off) ideal_air.heating_availability = schedule ideal_air.cooling_availability = schedule hvac_dict = ideal_air.to_dict() new_ideal_air = IdealAirSystem.from_dict(hvac_dict) assert new_ideal_air == ideal_air assert hvac_dict == new_ideal_air.to_dict()
def test_ideal_air_to_dict(): """Test the to_dict method.""" ideal_air = IdealAirSystem('Passive House HVAC System') ideal_air.economizer_type = 'DifferentialEnthalpy' ideal_air.demand_controlled_ventilation = True ideal_air.sensible_heat_recovery = 0.75 ideal_air.latent_heat_recovery = 0.6 ideal_air.heating_air_temperature = 40 ideal_air.cooling_air_temperature = 15 ideal_air.heating_limit = 2000 ideal_air.cooling_limit = 3500 sch_day = ScheduleDay( 'Day Control', [0, 1, 0], [Time(0, 0), Time(8, 0), Time(22, 0)]) schedule = ScheduleRuleset('HVAC Control', sch_day, None, schedule_types.on_off) ideal_air.heating_availability = schedule ideal_air.cooling_availability = schedule ideal_air_dict = ideal_air.to_dict(abridged=True) assert ideal_air_dict['economizer_type'] == 'DifferentialEnthalpy' assert ideal_air_dict['demand_controlled_ventilation'] == True assert ideal_air_dict['sensible_heat_recovery'] == 0.75 assert ideal_air_dict['latent_heat_recovery'] == 0.6 assert ideal_air_dict['heating_air_temperature'] == 40 assert ideal_air_dict['cooling_air_temperature'] == 15 assert ideal_air_dict['heating_limit'] == 2000 assert ideal_air_dict['cooling_limit'] == 3500 assert ideal_air_dict['heating_availability'] == 'HVAC Control' assert ideal_air_dict['cooling_availability'] == 'HVAC Control'