Ejemplo n.º 1
0
def test_color_face():
    """Test ColorFace."""
    pts_1 = [Point3D(0, 0, 0), Point3D(0, 10, 0), Point3D(10, 10, 0), Point3D(10, 0, 0)]
    pts_2 = [Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(0, 10, 3), Point3D(0, 10, 0)]
    pts_3 = [Point3D(0, 0, 0), Point3D(10, 0, 0), Point3D(10, 0, 3), Point3D(0, 0, 3)]
    pts_4 = [Point3D(10, 10, 0), Point3D(0, 10, 0), Point3D(0, 10, 3), Point3D(10, 10, 3)]
    pts_5 = [Point3D(10, 10, 0), Point3D(10, 0, 0), Point3D(10, 0, 3), Point3D(10, 10, 3)]
    pts_6 = [Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(0, 10, 3), Point3D(0, 0, 3)]
    face_1 = Face('Face1', Face3D(pts_1))
    face_2 = Face('Face2', Face3D(pts_2))
    face_3 = Face('Face3', Face3D(pts_3))
    face_4 = Face('Face4', Face3D(pts_4))
    face_5 = Face('Face5', Face3D(pts_5))
    face_6 = Face('Face6', Face3D(pts_6))
    face_2.apertures_by_ratio(0.4, 0.01)
    face_2.apertures[0].overhang(0.5, indoor=False)
    face_2.apertures[0].overhang(0.5, indoor=True)
    face_2.apertures[0].move_shades(Vector3D(0, 0, -0.5))
    door_verts = [Point3D(2, 10, 0.1), Point3D(1, 10, 0.1),
                  Point3D(1, 10, 2.5), Point3D(2, 10, 2.5)]
    aperture_verts = [Point3D(4.5, 5, 1), Point3D(2.5, 5, 1),
                      Point3D(2.5, 5, 2.5), Point3D(4.5, 5, 2.5)]
    door = Door('FrontDoor', Face3D(door_verts))
    aperture = Aperture('Partition', Face3D(aperture_verts))
    table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1)))
    table = Shade('Table', table_geo)
    tree_canopy_geo = Face3D.from_regular_polygon(6, 2, Plane(o=Point3D(5, -3, 4)))
    tree_canopy = Shade('TreeCanopy', tree_canopy_geo)

    all_geo = [face_1, face_2, face_3, face_4, face_5, face_6, table, tree_canopy,
               aperture, door]
    color_face1 = ColorFace(all_geo, 'display_name')
    color_face2 = ColorFace(all_geo, 'boundary_condition')

    assert len(color_face1.faces) == len(color_face2.faces) == len(all_geo)
    assert len(color_face1.flat_faces) == len(color_face2.flat_faces) == len(all_geo) + 3
    assert color_face1.flat_geometry[1].has_holes  # ensure punched geometry is used
    assert color_face1.attr_name == color_face1.attr_name_end == 'display_name'
    assert color_face2.attr_name == color_face2.attr_name_end == 'boundary_condition'
    assert color_face1.attributes == \
        ('Face1', 'Face2', 'Face2_Glz0', 'Face2_Glz0_OutOverhang0',
         'Face2_Glz0_InOverhang0', 'Face3', 'Face4', 'Face5', 'Face6',
         'Table', 'TreeCanopy', 'Partition', 'FrontDoor')
    assert color_face2.attributes == \
        ('Ground', 'Outdoors', 'Outdoors', 'N/A', 'N/A', 'Outdoors', 'Outdoors',
         'Outdoors', 'Outdoors', 'N/A', 'N/A', 'Outdoors', 'Outdoors')
    assert isinstance(color_face1.graphic_container, GraphicContainer)
    assert len(color_face1.attributes_unique) == \
        len(color_face1.graphic_container.legend.segment_colors) == \
        len(color_face1.attributes)
    assert len(color_face2.attributes_unique) == \
        len(color_face2.graphic_container.legend.segment_colors) == 3
    assert isinstance(color_face1.min_point, Point3D)
    assert isinstance(color_face1.max_point, Point3D)
Ejemplo n.º 2
0
def test_apertures_by_ratio():
    """Test the adding of apertures by ratio."""
    pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(5, 0,
                                                       3), Point3D(5, 0, 0))
    face = Face('Test_Wall', Face3D(pts))
    face.apertures_by_ratio(0.4, 0.01)

    assert len(face.apertures) == 1
    assert len(face.apertures[0].geometry.vertices) == 4
    assert sum([ap.area for ap in face.apertures]) == pytest.approx(15 * 0.4,
                                                                    rel=1e-2)
    assert face.punched_geometry.area == pytest.approx(15 * 0.6, rel=1e-2)
Ejemplo n.º 3
0
def test_model_init_from_objects():
    """Test the initialization of the Model from_objects."""
    pts_1 = [Point3D(0, 0, 0), Point3D(0, 10, 0), Point3D(10, 10, 0), Point3D(10, 0, 0)]
    pts_2 = [Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(0, 10, 3), Point3D(0, 10, 0)]
    pts_3 = [Point3D(0, 0, 0), Point3D(10, 0, 0), Point3D(10, 0, 3), Point3D(0, 0, 3)]
    pts_4 = [Point3D(10, 10, 0), Point3D(0, 10, 0), Point3D(0, 10, 3), Point3D(10, 10, 3)]
    pts_5 = [Point3D(10, 10, 0), Point3D(10, 0, 0), Point3D(10, 0, 3), Point3D(10, 10, 3)]
    pts_6 = [Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(0, 10, 3), Point3D(0, 0, 3)]
    face_1 = Face('Face 1', Face3D(pts_1))
    face_2 = Face('Face 2', Face3D(pts_2))
    face_3 = Face('Face 3', Face3D(pts_3))
    face_4 = Face('Face 4', Face3D(pts_4))
    face_5 = Face('Face 5', Face3D(pts_5))
    face_6 = Face('Face 6', Face3D(pts_6))
    face_2.apertures_by_ratio(0.4, 0.01)
    face_2.apertures[0].overhang(0.5, indoor=False)
    face_2.apertures[0].overhang(0.5, indoor=True)
    face_2.apertures[0].move_shades(Vector3D(0, 0, -0.5))
    door_verts = [Point3D(2, 10, 0.1), Point3D(1, 10, 0.1),
                  Point3D(1, 10, 2.5), Point3D(2, 10, 2.5)]
    aperture_verts = [Point3D(4.5, 5, 1), Point3D(2.5, 5, 1),
                      Point3D(2.5, 5, 2.5), Point3D(4.5, 5, 2.5)]
    door = Door('Front Door', Face3D(door_verts))
    aperture = Aperture('Partition', Face3D(aperture_verts))
    table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1)))
    table = Shade('Table', table_geo)
    tree_canopy_geo = Face3D.from_regular_polygon(6, 2, Plane(o=Point3D(5, -3, 4)))
    tree_canopy = Shade('Tree Canopy', tree_canopy_geo)

    model = Model.from_objects(
        'Tiny House', [face_1, face_2, face_3, face_4, face_5, face_6,
                       table, tree_canopy, aperture, door])

    assert len(model.rooms) == 0
    assert len(model.faces) == 6
    assert isinstance(model.faces[0], Face)
    assert len(model.shades) == 4
    assert isinstance(model.shades[0], Shade)
    assert len(model.apertures) == 2
    assert isinstance(model.apertures[0], Aperture)
    assert len(model.doors) == 1
    assert isinstance(model.doors[0], Door)
    assert len(model.orphaned_faces) == 6
    assert len(model.orphaned_shades) == 2
    assert len(model.orphaned_apertures) == 1
    assert len(model.orphaned_doors) == 1
Ejemplo n.º 4
0
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