def test_service_hot_water_init_from_idf(): """Test the initialization of Lighting from_idf.""" weekday_office = ScheduleDay('Weekday Office Water Use', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) saturday_office = ScheduleDay('Saturday Office Water Use', [0, 0.25, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) weekend_rule = ScheduleRule(saturday_office) weekend_rule.apply_weekend = True schedule = ScheduleRuleset('Office Water Use', weekday_office, [weekend_rule], schedule_types.fractional) shw = ServiceHotWater('Open Office Zone Hot Water', 0.1, schedule) sched_dict = {schedule.identifier: schedule} room = Room.from_box('Test_Zone', 10, 10, 3) idf_str, sch_strs = shw.to_idf(room) for sch in sch_strs: sch_obj = ScheduleRuleset.from_idf_constant(sch) sched_dict[sch_obj.identifier] = sch_obj rebuilt_shw, room_id, flow = ServiceHotWater.from_idf( idf_str, room.floor_area, sched_dict) if (sys.version_info >= (3, 0)): assert shw == rebuilt_shw assert room_id == room.identifier assert flow == shw.flow_per_area * room.floor_area
def test_service_hot_water_average(): """Test the ServiceHotWater.average method.""" weekday_office = ScheduleDay('Weekday Office Water Use', [0, 1, 0.5, 0], [Time(0, 0), Time(9, 0), Time(17, 0), Time(19, 0)]) weekday_lobby = ScheduleDay('Weekday Lobby Water Use', [0.1, 1, 0.1], [Time(0, 0), Time(8, 0), Time(20, 0)]) weekend_office = ScheduleDay('Weekend Office Water Use', [0]) weekend_lobby = ScheduleDay('Weekend Office Water Use', [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 Water Use', weekday_office, [wknd_office_rule], schedule_types.fractional) lobby_schedule = ScheduleRuleset('Lobby Water Use', weekday_lobby, [wknd_lobby_rule], schedule_types.fractional) office_shws = ServiceHotWater( 'Office Hot Water', 0.05, office_schedule, 60, 0.3, 0.05) br_shws = ServiceHotWater( 'Bathroom Hot Water', 0.1, lobby_schedule, 50, 0.4, 0.1) office_avg = ServiceHotWater.average( 'Office Average Hot Water', [office_shws, br_shws]) assert office_avg.flow_per_area == pytest.approx(0.075, rel=1e-3) assert office_avg.target_temperature == pytest.approx(55.0, rel=1e-3) assert office_avg.sensible_fraction == pytest.approx(0.35, rel=1e-3) assert office_avg.latent_fraction == pytest.approx(0.075, rel=1e-3) week_vals = office_avg.schedule.values(end_date=Date(1, 7)) avg_vals = [0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.75, 0.75, 0.5, 0.05, 0.05, 0.05, 0.05] assert week_vals[:24] == [0.05] * 24 assert week_vals[24:48] == avg_vals
def test_service_hot_water_dict_methods(): """Test the to/from dict methods.""" weekday_office = ScheduleDay('Weekday Office Water Use', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) saturday_office = ScheduleDay('Saturday Office Water Use', [0, 0.25, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) weekend_rule = ScheduleRule(saturday_office) weekend_rule.apply_weekend = True schedule = ScheduleRuleset('Office Water Use', weekday_office, [weekend_rule], schedule_types.fractional) shw = ServiceHotWater('Open Office Zone Hot Water', 0.1, schedule) shw_dict = shw.to_dict() new_shw = ServiceHotWater.from_dict(shw_dict) assert new_shw == shw assert shw_dict == new_shw.to_dict()
def program_type_office(directory): dest_file = os.path.join(directory, 'program_type_office.json') program_obj = office_program.duplicate() 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) program_obj.service_hot_water = shw with open(dest_file, 'w') as fp: json.dump(program_obj.to_dict(abridged=False), fp, indent=4)
def test_service_hot_water_equality(): """Test the equality of ServiceHotWater objects.""" weekday_office = ScheduleDay('Weekday Office Water Use', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) saturday_office = ScheduleDay('Saturday Office Water Use', [0, 0.25, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) weekend_rule = ScheduleRule(saturday_office) weekend_rule.apply_weekend = True schedule = ScheduleRuleset('Office Water Use', weekday_office, [weekend_rule], schedule_types.fractional) shw = ServiceHotWater('Open Office Zone Hot Water', 0.1, schedule) shw_dup = shw.duplicate() shw_alt = ServiceHotWater( 'Open Office Zone Hot Water', 0.1, ScheduleRuleset.from_constant_value('Constant', 1, schedule_types.fractional)) assert shw is shw assert shw is not shw_dup assert shw == shw_dup shw_dup.flow_per_area = 0.2 assert shw != shw_dup assert shw != shw_alt
def test_service_hot_water_lockability(): """Test the lockability of ServiceHotWater objects.""" weekday_office = ScheduleDay('Weekday Office Water Use', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) saturday_office = ScheduleDay('Saturday Office Water Use', [0, 0.25, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) weekend_rule = ScheduleRule(saturday_office) weekend_rule.apply_weekend = True schedule = ScheduleRuleset('Office Water Use', weekday_office, [weekend_rule], schedule_types.fractional) shw = ServiceHotWater('Open Office Zone Hot Water', 0.1, schedule) shw.flow_per_area = 0.2 shw.lock() with pytest.raises(AttributeError): shw.flow_per_area = 0.25 with pytest.raises(AttributeError): shw.schedule.default_day_schedule.remove_value_by_time(Time(17, 0)) shw.unlock() shw.flow_per_area = 0.25 with pytest.raises(AttributeError): shw.schedule.default_day_schedule.remove_value_by_time(Time(17, 0))
def test_init_from_watts_per_area(): """Test the initialization of ServiceHotWater from_watts_per_area.""" 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.from_watts_per_area('Office Hot Water', 10, schedule) assert shw.identifier == 'Office Hot Water' assert 0.1 < shw.flow_per_area < 0.2 assert shw.schedule.identifier == 'Office Water Use' assert shw.schedule.schedule_type_limit == schedule_types.fractional assert shw.schedule == schedule assert shw.target_temperature == 60 assert shw.sensible_fraction == 0.2 assert shw.latent_fraction == 0.05 assert shw.lost_fraction == 0.75
def model_energy_service_hot_water(directory): room = Room.from_box('TinyHouseZone', 5, 10, 3) room.properties.energy.program_type = prog_type_lib.office_program 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.service_hot_water = shw room.properties.energy.add_default_ideal_air() model = Model('TinyHouse', [room]) dest_file = os.path.join(directory, 'model_energy_service_hot_water.hbjson') with open(dest_file, 'w') as fp: json.dump(model.to_dict(included_prop=['energy']), fp, indent=4)
def test_service_hot_water_init(): """Test the initialization of ServiceHotWater and basic properties.""" 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) str(shw) # test the string representation assert shw.identifier == 'Office Hot Water' assert shw.flow_per_area == 0.1 assert shw.schedule.identifier == 'Office Water Use' assert shw.schedule.schedule_type_limit == schedule_types.fractional assert shw.schedule == schedule assert shw.target_temperature == 60 assert shw.sensible_fraction == 0.2 assert shw.latent_fraction == 0.05 assert shw.lost_fraction == 0.75
def test_run_idf_hot_water(): """Test the Model.to.idf and run_idf method with a model possessing hot water.""" # Get input Model room = Room.from_box('TinyHouseZone', 5, 10, 3) room.properties.energy.program_type = office_program 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.service_hot_water = shw room.properties.energy.add_default_ideal_air() 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(1, 7) # 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_shw', '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_service_hot_water_setability(): """Test the setting of properties of ServiceHotWater.""" 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) constant = ScheduleRuleset.from_constant_value( 'Constant Water Use', 1, schedule_types.fractional) shw = ServiceHotWater('Office Hot Water', 0.1, schedule) shw.identifier = 'Office Zone Hot Water' assert shw.identifier == 'Office Zone Hot Water' shw.flow_per_area = 0.05 assert shw.flow_per_area == 0.05 shw.schedule = constant assert shw.schedule == constant assert shw.schedule.values() == [1] * 8760 shw.target_temperature = 25 assert shw.target_temperature == 25 shw.sensible_fraction = 0.25 assert shw.sensible_fraction == 0.25 shw.latent_fraction = 0.1 assert shw.latent_fraction == 0.1
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)
try: from honeybee_energy.load.hotwater import ServiceHotWater 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 ServiceHotWater name if none is provided name = clean_and_id_ep_string('ServiceHotWater') if _name_ is None else \ clean_ep_string(_name_) # get the schedule if isinstance(_schedule, str): _schedule = schedule_by_identifier(_schedule) # get default radiant, latent, and lost fractions _target_temp_ = _target_temp_ if _target_temp_ is not None else 60 _sensible_fract_ = _sensible_fract_ if _sensible_fract_ is not None else 0.2 _latent_fract_ = _latent_fract_ if _latent_fract_ is not None else 0.05 # create the ServiceHotWater object hot_water = ServiceHotWater(name, _flow_per_area, _schedule, _target_temp_, _sensible_fract_, _latent_fract_) if _name_ is not None: hot_water.display_name = _name_
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 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