Exemplo n.º 1
0
def test_dict_to_object_bc():
    """Test the dict_to_object method with boundary conditions."""
    srf = Surface(['AdjacenyFace', 'AdjacentRoom'])
    out = Outdoors()
    bc_dict = srf.to_dict()

    assert isinstance(dict_to_object(bc_dict), Surface)
def test_surface_custom():
    ap_adj_names = ('AdjacentAperture', 'AdjacentFace', 'AdjacentRoom')
    face_adj_names = ('AdjacentFace', 'AdjacentRoom')
    ap_bc = Surface(ap_adj_names, True)
    face_bc = Surface(face_adj_names, False)
    assert ap_bc.name == face_bc.name == 'Surface'
    assert ap_bc.boundary_condition_objects == ap_adj_names
    assert face_bc.boundary_condition_objects == face_adj_names
    with pytest.raises(AssertionError):
        ap_bc = Surface(face_adj_names, True)
    with pytest.raises(AssertionError):
        face_bc = Surface(ap_adj_names, False)
Exemplo n.º 3
0
    def add_window_to_face(self, face, tolerance=0.01):
        """Add Apertures to a Honeybee Face using these Window Parameters.

        Args:
            face: A honeybee-core Face object.
            tolerance: Optional tolerance value. Default: 0.01, suitable for
                objects in meters.
        """
        width_seg = LineSegment3D.from_end_points(face.geometry[0],
                                                  face.geometry[1])
        height_seg = LineSegment3D.from_end_points(face.geometry[1],
                                                   face.geometry[2])
        max_width = width_seg.length * 0.99
        max_height = (height_seg.length * 0.99) - self.sill_height
        final_width = max_width if self.width > max_width else self.width
        final_height = max_height if self.height > max_height else self.height
        if final_height > 0:
            face.aperture_by_width_height(final_width, final_height,
                                          self.sill_height)
            # if the Aperture is interior, set adjacent boundary condition
            if isinstance(face._boundary_condition, Surface):
                ids = face._boundary_condition.boundary_condition_objects
                adj_ap_id = '{}_Glz1'.format(ids[0])
                final_ids = (adj_ap_id, ) + ids
                face.apertures[0].boundary_condition = Surface(final_ids, True)
def test_surface_to_dict():
    ap_adj_names = ('AdjacentAperture', 'AdjacentFace', 'AdjacentRoom')
    face_adj_names = ('AdjacentFace', 'AdjacentRoom')
    ap_bc = Surface(ap_adj_names, True)
    face_bc = Surface(face_adj_names, False)
    ap_bc_dict = ap_bc.to_dict()
    assert ap_bc_dict['type'] == 'Surface'
    assert ap_bc_dict['boundary_condition_objects'] == ap_adj_names
    face_bc_dict = face_bc.to_dict()
    assert face_bc_dict['type'] == 'Surface'
    assert face_bc_dict['boundary_condition_objects'] == face_adj_names
Exemplo n.º 5
0
    def add_window_to_face(self, face, tolerance=0.01):
        """Add Apertures to a Honeybee Face using these Window Parameters.

        Args:
            face: A honeybee-core Face object.
            tolerance: Optional tolerance value. Default: 0.01, suitable for
                objects in meters.
        """
        scale_factor = self.window_ratio**.5
        ap_face = face.geometry.scale(scale_factor, face.geometry.center)
        aperture = Aperture('{}_Glz1'.format(face.identifier), ap_face)
        aperture._parent = face
        face.add_aperture(aperture)
        # if the Aperture is interior, set adjacent boundary condition
        if isinstance(face._boundary_condition, Surface):
            ids = face._boundary_condition.boundary_condition_objects
            adj_ap_id = '{}_Glz1'.format(ids[0])
            final_ids = (adj_ap_id, ) + ids
            aperture.boundary_condition = Surface(final_ids, True)
Exemplo n.º 6
0
    def add_window_to_face(self, face, tolerance=0.01):
        """Add Apertures to a Honeybee Face using these Window Parameters.

        Args:
            face: A honeybee-core Face object.
            tolerance: The maximum difference between point values for them to be
                considered a part of a rectangle. Default: 0.01, suitable for
                objects in meters.
        """
        face.apertures_by_ratio_rectangle(self.window_ratio,
                                          self.window_height, self.sill_height,
                                          self.horizontal_separation,
                                          self.vertical_separation, tolerance)
        # if the Aperture is interior, set adjacent boundary condition
        if isinstance(face._boundary_condition, Surface):
            num_aps = face.apertures
            for i, ap in enumerate(face.apertures):
                ids = face._boundary_condition.boundary_condition_objects
                adj_ap_id = '{}_Glz{}'.format(ids[0], num_aps - i - 1)
                final_ids = (adj_ap_id, ) + ids
                ap.boundary_condition = Surface(final_ids, True)
Exemplo n.º 7
0
    def add_window_to_face(self, face, tolerance=0.01):
        """Add Apertures to a Honeybee Face using these Window Parameters.

        Args:
            face: A honeybee-core Face object.
            tolerance: Optional tolerance value. Default: 0.01, suitable for
                objects in meters.
        """
        # collect the global properties of the face that set limits on apertures
        wall_plane = face.geometry.plane
        width_seg = LineSegment3D.from_end_points(face.geometry[0],
                                                  face.geometry[1])
        height_seg = LineSegment3D.from_end_points(face.geometry[1],
                                                   face.geometry[2])
        max_width = width_seg.length * 0.99
        max_height = height_seg.length * 0.99

        # loop through each window and create its geometry
        for i, (o, wid,
                hgt) in enumerate(zip(self.origins, self.widths,
                                      self.heights)):
            final_width = max_width - o.x if wid + o.x > max_width else wid
            final_height = max_height - o.y if hgt + o.y > max_height else hgt
            if final_height > 0 and final_height > 0:  # inside wall boundary
                base_plane = Plane(wall_plane.n, wall_plane.xy_to_xyz(o),
                                   wall_plane.x)
                ap_face = Face3D.from_rectangle(final_width, final_height,
                                                base_plane)
                aperture = Aperture('{}_Glz{}'.format(face.identifier, i + 1),
                                    ap_face)
                aperture._parent = face
                face.add_aperture(aperture)
                # if the Aperture is interior, set adjacent boundary condition
                if isinstance(face._boundary_condition, Surface):
                    ids = face._boundary_condition.boundary_condition_objects
                    adj_ap_id = '{}_Glz{}'.format(ids[0], i + 1)
                    final_ids = (adj_ap_id, ) + ids
                    aperture.boundary_condition = Surface(final_ids, True)
Exemplo n.º 8
0
    def add_window_to_face(self, face, tolerance=0.01):
        """Add Apertures to a Honeybee Face using these Window Parameters.

        Args:
            face: A honeybee-core Face object.
            tolerance: Optional tolerance value. Default: 0.01, suitable for
                objects in meters.
        """
        wall_plane = face.geometry.plane

        # loop through each window and create its geometry
        for i, polygon in enumerate(self.polygons):
            pt3d = tuple(wall_plane.xy_to_xyz(pt) for pt in polygon)
            aperture = Aperture('{}_Glz{}'.format(face.identifier, i + 1),
                                Face3D(pt3d))
            aperture._parent = face
            face.add_aperture(aperture)
            # if the Aperture is interior, set adjacent boundary condition
            if isinstance(face._boundary_condition, Surface):
                ids = face._boundary_condition.boundary_condition_objects
                adj_ap_id = '{}_Glz{}'.format(ids[0], i + 1)
                final_ids = (adj_ap_id, ) + ids
                aperture.boundary_condition = Surface(final_ids, True)