示例#1
0
def model_complete_single_zone_office(directory):
    room = Room.from_box('Tiny_House_Office', 5, 10, 3)
    room.properties.energy.program_type = prog_type_lib.office_program
    room.properties.energy.add_default_ideal_air()

    stone = EnergyMaterial('Thick Stone', 0.3, 2.31, 2322, 832, 'Rough', 0.95,
                           0.75, 0.8)
    thermal_mass_constr = OpaqueConstruction('Thermal Mass Floor', [stone])
    room[0].properties.energy.construction = thermal_mass_constr

    south_face = room[3]
    south_face.apertures_by_ratio(0.4, 0.01)
    south_face.apertures[0].overhang(0.5, indoor=False)
    south_face.apertures[0].overhang(0.5, indoor=True)
    south_face.move_shades(Vector3D(0, 0, -0.5))
    light_shelf_out = ShadeConstruction('Outdoor_Light_Shelf', 0.5, 0.5)
    light_shelf_in = ShadeConstruction('Indoor_Light_Shelf', 0.7, 0.7)
    south_face.apertures[0].outdoor_shades[
        0].properties.energy.construction = light_shelf_out
    south_face.apertures[0].indoor_shades[
        0].properties.energy.construction = light_shelf_in

    north_face = room[1]
    north_face.overhang(0.25, indoor=False)
    door_verts = [
        Point3D(2, 10, 0.1),
        Point3D(1, 10, 0.1),
        Point3D(1, 10, 2.5),
        Point3D(2, 10, 2.5)
    ]
    door = Door('Front_Door', Face3D(door_verts))
    north_face.add_door(door)

    aperture_verts = [
        Point3D(4.5, 10, 1),
        Point3D(2.5, 10, 1),
        Point3D(2.5, 10, 2.5),
        Point3D(4.5, 10, 2.5)
    ]
    aperture = Aperture('Front_Aperture', Face3D(aperture_verts))
    triple_pane = WindowConstruction(
        'Triple Pane Window',
        [clear_glass, air_gap, clear_glass, air_gap, clear_glass])
    aperture.properties.energy.construction = triple_pane
    north_face.add_aperture(aperture)

    tree_canopy_geo = Face3D.from_regular_polygon(
        6, 2, Plane(Vector3D(0, 0, 1), Point3D(5, -3, 4)))
    tree_canopy = Shade('Tree_Canopy', tree_canopy_geo)

    table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1)))
    table = Shade('Table', table_geo)
    room.add_indoor_shade(table)

    model = Model('Tiny_House', [room], orphaned_shades=[tree_canopy])

    dest_file = os.path.join(directory,
                             'model_complete_single_zone_office.json')
    with open(dest_file, 'w') as fp:
        json.dump(model.to_dict(), fp, indent=4)
示例#2
0
def test_apertures_and_shades():
    """Test the addition of apertures and shades to a room."""
    room = Room.from_box('ShoeBoxZone', 5, 10, 3)
    south_face = room[3]
    south_face.apertures_by_ratio(0.5, 0.01)
    table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1)))
    room.add_indoor_shade(Shade('Table', table_geo))
    tree_canopy_geo = Face3D.from_regular_polygon(6, 2, Plane(o=Point3D(5, -3, 4)))
    room.add_outdoor_shade(Shade('Tree Canopy', tree_canopy_geo))

    assert room.exterior_aperture_area == pytest.approx(7.5, rel=1e-3)
    assert len(room.indoor_shades) == 1
    assert len(room.outdoor_shades) == 1
    assert room.indoor_shades[0].parent == room
    assert room.outdoor_shades[0].parent == room
    room.remove_indoor_shades()
    assert len(room.indoor_shades) == 0
    room.remove_outdoor_shades()
    assert len(room.outdoor_shades) == 0

    room.add_indoor_shade(Shade('Table', table_geo))
    room.add_outdoor_shade(Shade('Tree Canopy', tree_canopy_geo))
    assert len(room.indoor_shades) == 1
    assert len(room.outdoor_shades) == 1
    assert room.indoor_shades[0].has_parent
    assert room.outdoor_shades[0].has_parent
    room.remove_shades()
    assert len(room.indoor_shades) == 0
    assert len(room.outdoor_shades) == 0
示例#3
0
def test_writer_to_idf():
    """Test the Shade to_idf method."""
    verts = [
        Point3D(0, 0, 0),
        Point3D(1, 0, 0),
        Point3D(1, 0, 3),
        Point3D(0, 0, 3)
    ]
    shade = Shade('overhang', Face3D(verts))

    assert hasattr(shade.to, 'idf')
    idf_string = shade.to.idf(shade)
    assert 'overhang,' in idf_string
    assert 'Shading:Building:Detailed,' in idf_string
    assert 'ShadingProperty:Reflectance' not in idf_string

    shade = Shade('overhang', Face3D(verts))
    light_shelf = ShadeConstruction('Light Shelf', 0.5, 0.5, True)
    shade.properties.energy.construction = light_shelf
    fritted_glass_trans = ScheduleRuleset.from_constant_value(
        'FrittedGlass', 0.5, schedule_types.fractional)
    shade.properties.energy.transmittance_schedule = fritted_glass_trans

    assert hasattr(shade.to, 'idf')
    idf_string = shade.to.idf(shade)
    assert 'overhang,' in idf_string
    assert 'Shading:Building:Detailed,' in idf_string
    assert 'ShadingProperty:Reflectance' in idf_string
    assert 'FrittedGlass' in idf_string
示例#4
0
def test_to_dict():
    """Test the Shade to_dict method with energy properties."""
    verts = [
        Point3D(0, 0, 0),
        Point3D(1, 0, 0),
        Point3D(1, 0, 3),
        Point3D(0, 0, 3)
    ]
    shade = Shade('overhang', Face3D(verts))

    shade_dict = shade.to_dict()
    assert 'properties' in shade_dict
    assert shade_dict['properties']['type'] == 'ShadeProperties'
    assert 'energy' in shade_dict['properties']
    assert shade_dict['properties']['energy'][
        'type'] == 'ShadeEnergyProperties'

    light_shelf = ShadeConstruction('Light Shelf', 0.5, 0.5, True)
    shade.properties.energy.construction = light_shelf
    shade_dict = shade.to_dict()
    assert 'construction' in shade_dict['properties']['energy']
    assert shade_dict['properties']['energy']['construction'][
        'solar_reflectance'] == 0.5
    assert shade_dict['properties']['energy']['construction'][
        'visible_reflectance'] == 0.5
    assert shade_dict['properties']['energy']['construction']['is_specular']

    fritted_glass_trans = ScheduleRuleset.from_constant_value(
        'Fritted Glass', 0.5, schedule_types.fractional)
    shade.properties.energy.transmittance_schedule = fritted_glass_trans
    shade_dict = shade.to_dict()
    assert 'transmittance_schedule' in shade_dict['properties']['energy']
    assert shade_dict['properties']['energy'][
        'transmittance_schedule'] is not None
示例#5
0
    def shade_representation(self, cap=False, tolerance=0.01):
        """A list of honeybee Shade objects representing the story geometry.

        This accounts for the story multiplier and can be used to account for
        this Story's shade in the simulation of another nearby Story.

        Args:
            cap: Boolean to note whether the shade representation should be capped
                with a top face. Usually, this is not necessary to account for
                blocked sun and is only needed when it's important to account for
                reflected sun off of roofs. (Default: False).
            tolerance: The minimum distance between points at which they are
                not considered touching. Default: 0.01, suitable for objects
                in meters.
        """
        context_shades = []
        extru_vec = Vector3D(0, 0, self.floor_to_floor_height * self.multiplier)
        for i, seg in enumerate(self.outline_segments(tolerance)):
            try:
                extru_geo = Face3D.from_extrusion(seg, extru_vec)
                shd_id = '{}_{}'.format(self.identifier, i)
                context_shades.append(Shade(shd_id, extru_geo))
            except ZeroDivisionError:
                pass  # duplicate vertex resulting in a segment of length 0
        if cap:
            for i, s in enumerate(self.footprint(tolerance)):
                shd_id = '{}_Top_{}'.format(self.identifier, i)
                context_shades.append(Shade(shd_id, s.move(extru_vec)))
        return context_shades
示例#6
0
def reflect_state_shades():
    """Check to be sure that dynamic shades are reflected with their parent."""
    pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2,
                                                       2), Point3D(1, 2, 2))
    ap = Shade('TestShade', Face3D(pts))
    pts_1 = (Point3D(0, 0, 0), Point3D(2, 0, 0), Point3D(2, 2,
                                                         0), Point3D(0, 2, 0))
    shade = StateGeometry('RectangleShade', Face3D(pts_1))

    tint1 = RadianceShadeState(shades=[shade])
    ap.properties.radiance.dynamic_group_identifier = 'DeciduousTrees'
    ap.properties.radiance.states = [tint1]
    tint1.gen_geos_from_tmtx_thickness(0.05)

    new_ap = ap.duplicate()
    origin_1 = Point3D(1, 0, 2)
    normal_1 = Vector3D(1, 0, 0)
    plane_1 = Plane(normal_1, origin_1)
    new_ap.reflect(plane_1)
    new_shd = new_ap.properties.radiance.states[0].shades[0]
    assert new_shd.geometry[-1].x == pytest.approx(1, rel=1e-3)
    assert new_shd.geometry[-1].y == pytest.approx(1, rel=1e-3)
    assert new_shd.geometry[-1].z == pytest.approx(2, rel=1e-3)
    assert new_shd.geometry[1].x == pytest.approx(0, rel=1e-3)
    assert new_shd.geometry[1].y == pytest.approx(2, rel=1e-3)
    assert new_shd.geometry[1].z == pytest.approx(2, rel=1e-3)
示例#7
0
def test_to_from_dict_with_states():
    """Test the Shade from_dict method with radiance properties."""
    pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(1, 0,
                                                       3), Point3D(1, 0, 0))
    shd = Shade('TreeTrunk', Face3D(pts))
    shd1 = StateGeometry.from_vertices(
        'tree_foliage1', [[0, 0, 5], [2, 0, 5], [2, 2, 5], [0, 2, 5]])
    shd2 = StateGeometry.from_vertices(
        'tree_foliage2', [[0, 0, 5], [-2, 0, 5], [-2, 2, 5], [0, 2, 5]])

    trans1 = Glass.from_single_transmittance('TreeTrans1', 0.5)
    trans2 = Glass.from_single_transmittance('TreeTrans2', 0.27)
    trans3 = Glass.from_single_transmittance('TreeTrans3', 0.14)
    trans4 = Glass.from_single_transmittance('TreeTrans4', 0.01)

    tr1 = RadianceShadeState(trans1)
    tr2 = RadianceShadeState(trans2)
    tr3 = RadianceShadeState(trans3, [shd1])
    tr4 = RadianceShadeState(trans4, [shd1.duplicate(), shd2])
    states = (tr1, tr2, tr3, tr4)

    shd.properties.radiance.dynamic_group_identifier = 'DeciduousTrees'
    shd.properties.radiance.states = states

    ad = shd.to_dict()
    new_shade = Shade.from_dict(ad)
    assert new_shade.properties.radiance.dynamic_group_identifier == \
        shd.properties.radiance.dynamic_group_identifier
    state_ids1 = [state.modifier for state in states]
    state_ids2 = [
        state.modifier for state in new_shade.properties.radiance.states
    ]
    assert state_ids1 == state_ids2
    assert new_shade.to_dict() == ad
示例#8
0
def test_duplicate():
    """Test what happens to radiance properties when duplicating a Shade."""
    verts = [
        Point3D(0, 0, 3),
        Point3D(1, 0, 3),
        Point3D(1, 1, 3),
        Point3D(0, 1, 3)
    ]
    foliage = Glass.from_single_transmittance('Foliage', 0.2)
    shade_original = Shade('tree', Face3D(verts))
    shade_dup_1 = shade_original.duplicate()

    assert shade_original.properties.radiance.host is shade_original
    assert shade_dup_1.properties.radiance.host is shade_dup_1
    assert shade_original.properties.radiance.host is not shade_dup_1.properties.radiance.host

    assert shade_original.properties.radiance.modifier == \
        shade_dup_1.properties.radiance.modifier
    shade_dup_1.properties.radiance.modifier = foliage
    assert shade_original.properties.radiance.modifier != \
        shade_dup_1.properties.radiance.modifier

    shade_dup_2 = shade_dup_1.duplicate()

    assert shade_dup_1.properties.radiance.modifier == \
        shade_dup_2.properties.radiance.modifier
    shade_dup_2.properties.radiance.modifier = None
    assert shade_dup_1.properties.radiance.modifier != \
        shade_dup_2.properties.radiance.modifier
示例#9
0
def test_rotate():
    """Test the shade rotate method."""
    pts = (Point3D(0, 0, 2), Point3D(2, 0, 2), Point3D(2, 2,
                                                       2), Point3D(0, 2, 2))
    plane = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 2))
    shade = Shade('RectangleShade', Face3D(pts, plane))
    origin = Point3D(0, 0, 0)
    axis = Vector3D(1, 0, 0)

    test_1 = shade.duplicate()
    test_1.rotate(axis, 180, origin)
    assert test_1.geometry[0].x == pytest.approx(0, rel=1e-3)
    assert test_1.geometry[0].y == pytest.approx(0, rel=1e-3)
    assert test_1.geometry[0].z == pytest.approx(-2, rel=1e-3)
    assert test_1.geometry[2].x == pytest.approx(2, rel=1e-3)
    assert test_1.geometry[2].y == pytest.approx(-2, rel=1e-3)
    assert test_1.geometry[2].z == pytest.approx(-2, rel=1e-3)
    assert shade.area == test_1.area
    assert len(shade.vertices) == len(test_1.vertices)

    test_2 = shade.duplicate()
    test_2.rotate(axis, 90, origin)
    assert test_2.geometry[0].x == pytest.approx(0, rel=1e-3)
    assert test_2.geometry[0].y == pytest.approx(-2, rel=1e-3)
    assert test_2.geometry[0].z == pytest.approx(0, rel=1e-3)
    assert test_2.geometry[2].x == pytest.approx(2, rel=1e-3)
    assert test_2.geometry[2].y == pytest.approx(-2, rel=1e-3)
    assert test_2.geometry[2].z == pytest.approx(2, rel=1e-3)
    assert shade.area == test_2.area
    assert len(shade.vertices) == len(test_2.vertices)
示例#10
0
def test_rotate_xy():
    """Test the Shade rotate_xy method."""
    pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2,
                                                       2), Point3D(1, 2, 2))
    plane = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 2))
    shade = Shade('RectangleShade', Face3D(pts, plane))
    origin_1 = Point3D(1, 1, 0)

    test_1 = shade.duplicate()
    test_1.rotate_xy(180, origin_1)
    assert test_1.geometry[0].x == pytest.approx(1, rel=1e-3)
    assert test_1.geometry[0].y == pytest.approx(1, rel=1e-3)
    assert test_1.geometry[0].z == pytest.approx(2, rel=1e-3)
    assert test_1.geometry[2].x == pytest.approx(0, rel=1e-3)
    assert test_1.geometry[2].y == pytest.approx(0, rel=1e-3)
    assert test_1.geometry[2].z == pytest.approx(2, rel=1e-3)

    test_2 = shade.duplicate()
    test_2.rotate_xy(90, origin_1)
    assert test_2.geometry[0].x == pytest.approx(1, rel=1e-3)
    assert test_2.geometry[0].y == pytest.approx(1, rel=1e-3)
    assert test_1.geometry[0].z == pytest.approx(2, rel=1e-3)
    assert test_2.geometry[2].x == pytest.approx(0, rel=1e-3)
    assert test_2.geometry[2].y == pytest.approx(2, rel=1e-3)
    assert test_1.geometry[2].z == pytest.approx(2, rel=1e-3)
示例#11
0
def test_to_dict_single_zone():
    """Test the Model to_dict method with a single zone model."""
    room = Room.from_box('Tiny_House_Zone', 5, 10, 3)

    dark_floor = Plastic.from_single_reflectance('DarkFloor', 0.1)
    room[0].properties.radiance.modifier = dark_floor

    south_face = room[3]
    south_face.apertures_by_ratio(0.4, 0.01)
    south_face.apertures[0].overhang(0.5, indoor=False)
    south_face.apertures[0].overhang(0.5, indoor=True)
    south_face.move_shades(Vector3D(0, 0, -0.5))
    light_shelf_out = Plastic.from_single_reflectance('OutdoorLightShelf', 0.5)
    light_shelf_in = Plastic.from_single_reflectance('IndoorLightShelf', 0.7)
    south_face.apertures[0].outdoor_shades[0].properties.radiance.modifier = light_shelf_out
    south_face.apertures[0].indoor_shades[0].properties.radiance.modifier = light_shelf_in

    north_face = room[1]
    north_face.overhang(0.25, indoor=False)
    door_verts = [Point3D(2, 10, 0.1), Point3D(1, 10, 0.1),
                  Point3D(1, 10, 2.5), Point3D(2, 10, 2.5)]
    door = Door('Front_Door', Face3D(door_verts))
    north_face.add_door(door)

    aperture_verts = [Point3D(4.5, 10, 1), Point3D(2.5, 10, 1),
                      Point3D(2.5, 10, 2.5), Point3D(4.5, 10, 2.5)]
    aperture = Aperture('Front_Aperture', Face3D(aperture_verts))
    triple_pane = Glass.from_single_transmittance('CustomTriplePane', 0.3)
    aperture.properties.radiance.modifier = triple_pane
    north_face.add_aperture(aperture)

    tree_canopy_geo = Face3D.from_regular_polygon(
        6, 2, Plane(Vector3D(0, 0, 1), Point3D(5, -3, 4)))
    tree_canopy = Shade('Tree_Canopy', tree_canopy_geo)

    table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1)))
    table = Shade('Table', table_geo)
    room.add_indoor_shade(table)

    model = Model('Tiny_House', [room], orphaned_shades=[tree_canopy])

    model_dict = model.to_dict()

    assert 'radiance' in model_dict['properties']
    assert 'modifiers' in model_dict['properties']['radiance']
    assert 'modifier_sets' in model_dict['properties']['radiance']

    assert len(model_dict['properties']['radiance']['modifiers']) == 5
    assert len(model_dict['properties']['radiance']['modifier_sets']) == 0

    assert model_dict['rooms'][0]['faces'][0]['properties']['radiance']['modifier'] == \
        dark_floor.identifier
    south_ap_dict = model_dict['rooms'][0]['faces'][3]['apertures'][0]
    assert south_ap_dict['outdoor_shades'][0]['properties']['radiance']['modifier'] == \
        light_shelf_out.identifier
    assert south_ap_dict['indoor_shades'][0]['properties']['radiance']['modifier'] == \
        light_shelf_in.identifier
    assert model_dict['rooms'][0]['faces'][1]['apertures'][0]['properties']['radiance']['modifier'] == \
        triple_pane.identifier
示例#12
0
def test_writer_to_rad():
    """Test the Model to.rad method."""
    room = Room.from_box('Tiny_House_Zone', 5, 10, 3)

    dark_floor = Plastic.from_single_reflectance('DarkFloor', 0.1)
    room[0].properties.radiance.modifier = dark_floor

    south_face = room[3]
    south_face.apertures_by_ratio(0.4, 0.01)
    south_face.apertures[0].overhang(0.5, indoor=False)
    south_face.apertures[0].overhang(0.5, indoor=True)
    south_face.move_shades(Vector3D(0, 0, -0.5))
    light_shelf_out = Plastic.from_single_reflectance(
        'outdoor_light_shelf_0.5', 0.5)
    light_shelf_in = Plastic.from_single_reflectance('indoor_light_shelf_0.70',
                                                     0.7)
    south_face.apertures[0].outdoor_shades[
        0].properties.radiance.modifier = light_shelf_out
    south_face.apertures[0].indoor_shades[
        0].properties.radiance.modifier = light_shelf_in

    north_face = room[1]
    north_face.overhang(0.25, indoor=False)
    door_verts = [
        Point3D(2, 10, 0.1),
        Point3D(1, 10, 0.1),
        Point3D(1, 10, 2.5),
        Point3D(2, 10, 2.5)
    ]
    door = Door('Front_Door', Face3D(door_verts))
    north_face.add_door(door)

    aperture_verts = [
        Point3D(4.5, 10, 1),
        Point3D(2.5, 10, 1),
        Point3D(2.5, 10, 2.5),
        Point3D(4.5, 10, 2.5)
    ]
    aperture = Aperture('Front_Aperture', Face3D(aperture_verts))
    triple_pane = Glass.from_single_transmittance('custom_triple_pane_0.3',
                                                  0.3)
    aperture.properties.radiance.modifier = triple_pane
    north_face.add_aperture(aperture)

    tree_canopy_geo = Face3D.from_regular_polygon(
        6, 2, Plane(Vector3D(0, 0, 1), Point3D(5, -3, 4)))
    tree_canopy = Shade('Tree_Canopy', tree_canopy_geo)

    table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1)))
    table = Shade('Table', table_geo)
    room.add_indoor_shade(table)

    model = Model('Tiny_House', [room], orphaned_shades=[tree_canopy])

    assert hasattr(model.to, 'rad')
    rad_string = model.to.rad(model)
    assert len(rad_string) == 2
    assert 'outdoor_light_shelf_0.5' in rad_string[1]
    assert 'Front_Door' in rad_string[0]
示例#13
0
def test_to_from_dict():
    """Test the to/from dict of Shade objects."""
    vertices = [[0, 0, 0], [0, 10, 0], [0, 10, 3], [0, 0, 3]]
    shd = Shade.from_vertices('RectangleShade', vertices, True)

    shd_dict = shd.to_dict()
    new_shd = Shade.from_dict(shd_dict)
    assert isinstance(new_shd, Shade)
    assert new_shd.to_dict() == shd_dict
示例#14
0
 def to_honeybee(self):
     """Convert Dragonfly ContextShade to an array of Honeybee Shades."""
     shades = []
     for i, shd_geo in enumerate(self._geometry):
         # create the shade object
         shade = Shade('{}_{}'.format(self.identifier, i), shd_geo)
         shade.display_name = '{}_{}'.format(self.display_name, i)
         # transfer any extension properties assigned to the Shade
         shade._properties = self.properties.to_honeybee(shade)
         shades.append(shade)
     return shades
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)
示例#16
0
def test_from_dict():
    """Test the Shade from_dict method with radiance properties."""
    shade = Shade.from_vertices(
        'tree', [[0, 0, 0], [10, 0, 0], [10, 0, 10], [0, 0, 10]])
    foliage = Glass.from_single_transmittance('Foliage', 0.2)
    shade.properties.radiance.modifier = foliage

    shdd = shade.to_dict()
    new_shade = Shade.from_dict(shdd)
    assert new_shade.properties.radiance.modifier == foliage
    assert new_shade.to_dict() == shdd
示例#17
0
def test_shade_duplicate():
    """Test the duplication of shade objects."""
    pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(1, 0, 3), Point3D(1, 0, 0))
    shd_1 = Shade('Test Shade', Face3D(pts))
    shd_2 = shd_1.duplicate()

    assert shd_1 is not shd_2
    for i, pt in enumerate(shd_1.vertices):
        assert pt == shd_2.vertices[i]
    assert shd_1.name == shd_2.name

    shd_2.move(Vector3D(0, 1, 0))
    for i, pt in enumerate(shd_1.vertices):
        assert pt != shd_2.vertices[i]
示例#18
0
def test_scale():
    """Test the shade scale method."""
    pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2, 2), Point3D(1, 2, 2))
    plane = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 2))
    shade = Shade('Rectangle Shade', Face3D(pts, plane))

    new_shd = shade.duplicate()
    new_shd.scale(2)
    assert new_shd.geometry[0] == Point3D(2, 2, 4)
    assert new_shd.geometry[1] == Point3D(4, 2, 4)
    assert new_shd.geometry[2] == Point3D(4, 4, 4)
    assert new_shd.geometry[3] == Point3D(2, 4, 4)
    assert new_shd.area == shade.area * 2 ** 2
    assert new_shd.perimeter == shade.perimeter * 2
    assert new_shd.normal == shade.normal
示例#19
0
def test_check_duplicate_shade_names():
    """Test the check_duplicate_shade_names method."""
    room = Room.from_box('Tiny House Zone', 5, 10, 3)
    south_face = room[3]
    south_face.apertures_by_ratio(0.4, 0.01)
    table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1)))
    room.add_indoor_shade(Shade('Table', table_geo))

    model = Model('Test House', [room])
    assert model.check_duplicate_shade_names(False)
    tree_canopy_geo = Face3D.from_regular_polygon(6, 2, Plane(o=Point3D(5, -3, 4)))
    model.add_shade(Shade('Table', tree_canopy_geo))
    assert not model.check_duplicate_shade_names(False)
    with pytest.raises(ValueError):
        model.check_duplicate_shade_names(True)
示例#20
0
    def shade_representation_multiplier(self, exclude_index=0, cap=False,
                                        tolerance=0.01):
        """A list of honeybee Shade objects for just the "multiplier" part of the story.

        This includes all of the geometry along the height of the multiplier except
        for one of the floors (represented by the exclude_index). This will be an
        empty list if the story has a multiplier of 1.

        Args:
            exclude_index: An optional index for a story along the multiplier to
                be excluded from the shade representation. For example, if 0,
                the bottom geometry along the multiplier is excluded. (Default: 0).
            cap: Boolean to note whether the shade representation should be capped
                with a top face. Usually, this is not necessary to account for
                blocked sun and is only needed when it's important to account for
                reflected sun off of roofs. (Default: False).
            tolerance: The minimum distance between points at which they are
                not considered touching. Default: 0.01, suitable for objects
                in meters.
        """
        if self.multiplier == 1:
            return []
        # get the extrusion and moving vectors
        ftf, mult = self.floor_to_floor_height, self.multiplier
        context_shades, ceil_vecs, extru_vecs = [], [], []
        if exclude_index != 0:  # insert vectors for the bottom shade
            ceil_vecs.append(Vector3D(0, 0, 0))
            extru_vecs.append(Vector3D(0, 0, ftf * exclude_index))
        if exclude_index < mult:  # insert vectors for the top shade
            ceil_vecs.append(Vector3D(0, 0, ftf * (exclude_index + 1)))
            extru_vecs.append(Vector3D(0, 0, ftf * (mult - exclude_index - 1)))
        # loop through the segments and build up the shades
        for i, seg in enumerate(self.outline_segments(tolerance)):
            for ceil_vec, extru_vec in zip(ceil_vecs, extru_vecs):
                seg = seg.move(ceil_vec)
                try:
                    extru_geo = Face3D.from_extrusion(seg, extru_vec)
                    shd_id = '{}_{}'.format(self.identifier, i)
                    context_shades.append(Shade(shd_id, extru_geo))
                except ZeroDivisionError:
                    pass  # duplicate vertex resulting in a segment of length 0
        # cap the extrusions if requested
        if cap and exclude_index < mult:
            full_vec = Vector3D(0, 0, ftf * mult)
            for i, s in enumerate(self.footprint(tolerance)):
                shd_id = '{}_Top_{}'.format(self.identifier, i)
                context_shades.append(Shade(shd_id, s.move(full_vec)))
        return context_shades
示例#21
0
def test_writer_to_idf():
    """Test the Model to.idf method."""
    room = Room.from_box('TinyHouseZone', 5, 10, 3)
    room.properties.energy.program_type = office_program
    room.properties.energy.add_default_ideal_air()

    stone = EnergyMaterial('Thick Stone', 0.3, 2.31, 2322, 832, 'Rough',
                           0.95, 0.75, 0.8)
    thermal_mass_constr = OpaqueConstruction('Thermal Mass Floor', [stone])
    room[0].properties.energy.construction = thermal_mass_constr

    south_face = room[3]
    south_face.apertures_by_ratio(0.4, 0.01)
    south_face.apertures[0].overhang(0.5, indoor=False)
    south_face.apertures[0].overhang(0.5, indoor=True)
    south_face.move_shades(Vector3D(0, 0, -0.5))
    light_shelf_out = ShadeConstruction('OutdoorLightShelf', 0.5, 0.5)
    light_shelf_in = ShadeConstruction('IndoorLightShelf', 0.7, 0.7)
    south_face.apertures[0].outdoor_shades[0].properties.energy.construction = light_shelf_out
    south_face.apertures[0].indoor_shades[0].properties.energy.construction = light_shelf_in

    north_face = room[1]
    north_face.overhang(0.25, indoor=False)
    door_verts = [Point3D(2, 10, 0.1), Point3D(1, 10, 0.1),
                  Point3D(1, 10, 2.5), Point3D(2, 10, 2.5)]
    door = Door('FrontDoor', Face3D(door_verts))
    north_face.add_door(door)

    aperture_verts = [Point3D(4.5, 10, 1), Point3D(2.5, 10, 1),
                      Point3D(2.5, 10, 2.5), Point3D(4.5, 10, 2.5)]
    aperture = Aperture('FrontAperture', Face3D(aperture_verts))
    triple_pane = WindowConstruction(
        'Triple Pane Window', [clear_glass, air_gap, clear_glass, air_gap, clear_glass])
    aperture.properties.energy.construction = triple_pane
    north_face.add_aperture(aperture)

    tree_canopy_geo = Face3D.from_regular_polygon(
        6, 2, Plane(Vector3D(0, 0, 1), Point3D(5, -3, 4)))
    tree_canopy = Shade('TreeCanopy', tree_canopy_geo)

    table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1)))
    table = Shade('Table', table_geo)
    room.add_indoor_shade(table)

    model = Model('TinyHouse', [room], orphaned_shades=[tree_canopy])

    assert hasattr(model.to, 'idf')
    idf_string = model.to.idf(model, schedule_directory='./tests/idf/')
示例#22
0
def test_duplicate():
    """Test what happens to energy properties when duplicating a Shade."""
    verts = [
        Point3D(0, 0, 0),
        Point3D(1, 0, 0),
        Point3D(1, 0, 3),
        Point3D(0, 0, 3)
    ]
    shade_original = Shade('overhang', Face3D(verts))
    shade_dup_1 = shade_original.duplicate()
    light_shelf = ShadeConstruction('Light Shelf', 0.5, 0.5, True)
    bright_light_shelf = ShadeConstruction('Bright Light Shelf', 0.7, 0.7,
                                           True)
    fritted_glass_trans = ScheduleRuleset.from_constant_value(
        'Fritted Glass', 0.5, schedule_types.fractional)

    assert shade_original.properties.energy.host is shade_original
    assert shade_dup_1.properties.energy.host is shade_dup_1
    assert shade_original.properties.energy.host is not \
        shade_dup_1.properties.energy.host

    assert shade_original.properties.energy.construction == \
        shade_dup_1.properties.energy.construction
    shade_dup_1.properties.energy.construction = light_shelf
    assert shade_original.properties.energy.construction != \
        shade_dup_1.properties.energy.construction

    shade_dup_2 = shade_dup_1.duplicate()

    assert shade_dup_1.properties.energy.construction == \
        shade_dup_2.properties.energy.construction
    shade_dup_2.properties.energy.construction = bright_light_shelf
    assert shade_dup_1.properties.energy.construction != \
        shade_dup_2.properties.energy.construction

    assert shade_original.properties.energy.transmittance_schedule == \
        shade_dup_1.properties.energy.transmittance_schedule
    shade_dup_1.properties.energy.transmittance_schedule = fritted_glass_trans
    assert shade_original.properties.energy.transmittance_schedule != \
        shade_dup_1.properties.energy.transmittance_schedule

    shade_dup_3 = shade_dup_1.duplicate()

    assert shade_dup_1.properties.energy.transmittance_schedule == \
        shade_dup_3.properties.energy.transmittance_schedule
    shade_dup_3.properties.energy.transmittance_schedule = None
    assert shade_dup_1.properties.energy.transmittance_schedule != \
        shade_dup_3.properties.energy.transmittance_schedule
示例#23
0
def test_move():
    """Test the shade move method."""
    pts_1 = (Point3D(0, 0, 0), Point3D(2, 0, 0), Point3D(2, 2, 0), Point3D(0, 2, 0))
    plane_1 = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 0))
    shade = Shade('Rectangle Shade', Face3D(pts_1, plane_1))

    vec_1 = Vector3D(2, 2, 2)
    new_shd = shade.duplicate()
    new_shd.move(vec_1)
    assert new_shd.geometry[0] == Point3D(2, 2, 2)
    assert new_shd.geometry[1] == Point3D(4, 2, 2)
    assert new_shd.geometry[2] == Point3D(4, 4, 2)
    assert new_shd.geometry[3] == Point3D(2, 4, 2)
    assert new_shd.normal == shade.normal
    assert shade.area == new_shd.area
    assert shade.perimeter == new_shd.perimeter
示例#24
0
def test_from_honeybee():
    """Test the from_honeybee method of Model objects."""
    room_south = Room.from_box('SouthZone', 5, 5, 3, origin=Point3D(0, 0, 0))
    room_north = Room.from_box('NorthZone', 5, 5, 3, origin=Point3D(0, 5, 0))
    room_up = Room.from_box('UpZone', 5, 5, 3, origin=Point3D(0, 5, 3))
    room_south[1].apertures_by_ratio(0.4, 0.01)
    room_south[3].apertures_by_ratio(0.4, 0.01)
    room_north[3].apertures_by_ratio(0.4, 0.01)
    Room.solve_adjacency([room_south, room_north], 0.01)

    pts = (Point3D(0, -3, 0), Point3D(0, -3, 3), Point3D(1, -3, 3), Point3D(1, -3, 0))
    shade = Shade('TestShade', Face3D(pts))
    
    model = hb_model.Model('Test_Building', [room_south, room_north, room_up],
                           orphaned_shades=[shade], tolerance=0.01)
    
    model = Model.from_honeybee(model)

    assert len(model.context_shades) == 1
    assert len(model.buildings) == 1
    bldg = model.buildings[0]

    assert bldg.identifier == 'Test_Building'
    assert len(bldg.unique_stories) == 2

    bound_cs = [b for room in bldg.unique_room_2ds for b in room.boundary_conditions
                if isinstance(b, Surface)]
    assert len(bound_cs) == 2
    assert bound_cs[0].boundary_condition_objects == ('NorthZone..Face4', 'NorthZone')
    assert bound_cs[1].boundary_condition_objects == ('SouthZone..Face2', 'SouthZone')
示例#25
0
    def shade_representation(self, tolerance=0.01):
        """A list of honeybee Shade objects representing the building geometry.

        These can be used to account for this Building's shade in the simulation of
        another nearby Building.

        Args:
            tolerance: The minimum distance between points at which they are
                not considered touching. Default: 0.01, suitable for objects
                in meters.
        """
        context_shades = []
        for story in self.unique_stories:
            extru_vec = Vector3D(
                0, 0, story.floor_to_floor_height * story.multiplier)
            for i, seg in enumerate(story.outline_segments(tolerance)):
                try:
                    extru_geo = Face3D.from_extrusion(seg, extru_vec)
                    shd_id = '{}_{}_{}'.format(self.identifier,
                                               story.identifier, i)
                    context_shades.append(Shade(shd_id, extru_geo))
                except ZeroDivisionError:
                    pass  # duplicate vertex resulting in a segment of length 0
            # TODO: consider adding a Shade object to cap the extrusion
        return context_shades
示例#26
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
示例#27
0
def test_default_properties():
    """Test the auto-assigning of shade properties."""
    out_shade = Shade.from_vertices(
        'overhang', [[0, 0, 3], [1, 0, 3], [1, 1, 3], [0, 1, 3]])
    in_shade = Shade.from_vertices(
        'light_shelf', [[0, 0, 3], [-1, 0, 3], [-1, -1, 3], [0, -1, 3]])
    aperture = Aperture.from_vertices(
        'parent_aperture', [[0, 0, 0], [0, 10, 0], [0, 10, 3], [0, 0, 3]])

    assert out_shade.properties.radiance.modifier == generic_context
    assert in_shade.properties.radiance.modifier == generic_context

    aperture.add_outdoor_shade(out_shade)
    assert out_shade.properties.radiance.modifier == generic_exterior_shade

    aperture.add_indoor_shade(in_shade)
    assert in_shade.properties.radiance.modifier == generic_interior_shade
示例#28
0
def test_energy_properties():
    """Test the existence of the Shade energy properties."""
    shade = Shade.from_vertices('overhang',
                                [[0, 0, 3], [1, 0, 3], [1, 1, 3], [0, 1, 3]])

    assert hasattr(shade.properties, 'energy')
    assert isinstance(shade.properties.energy, ShadeEnergyProperties)
    assert isinstance(shade.properties.energy.construction, ShadeConstruction)
示例#29
0
def test_writer():
    """Test the Shade writer object."""
    vertices = [[0, 0, 0], [0, 10, 0], [0, 10, 3], [0, 0, 3]]
    shd = Shade.from_vertices('RectangleShade', vertices)

    writers = [mod for mod in dir(shd.to) if not mod.startswith('_')]
    for writer in writers:
        assert callable(getattr(shd.to, writer))
示例#30
0
def model_complete_holes(directory):
    bound_pts = [Point3D(0, 0), Point3D(9, 0), Point3D(9, 9), Point3D(0, 9)]
    hole_pts = [
        Point3D(3, 3, 0),
        Point3D(6, 3, 0),
        Point3D(6, 6, 0),
        Point3D(3, 6, 0)
    ]
    face = Face3D(bound_pts, None, [hole_pts])
    polyface = Polyface3D.from_offset_face(face, 3)
    room = Room.from_polyface3d('DonutZone', polyface)

    ap_bound_pts = [
        Point3D(0.5, 0, 0.5),
        Point3D(2.5, 0, 0.5),
        Point3D(2.5, 0, 2.5),
        Point3D(0.5, 0, 2.5)
    ]
    ap_hole_pts = [
        Point3D(1, 0, 1),
        Point3D(2, 0, 1),
        Point3D(2, 0, 2),
        Point3D(1, 0, 2)
    ]
    ap_face = Face3D(ap_bound_pts, None, [ap_hole_pts])
    ap = Aperture('HoleAperture', ap_face)
    for face in room.faces:
        if face.geometry.is_sub_face(ap_face, 0.01, 1.0):
            face.add_aperture(ap)

    shd_bound_pts = [
        Point3D(0, 0, 6),
        Point3D(9, 0, 6),
        Point3D(9, 9, 6),
        Point3D(0, 9, 6)
    ]
    shd_hole_pts1 = [
        Point3D(2, 2, 6),
        Point3D(4, 2, 6),
        Point3D(4, 4, 6),
        Point3D(2, 4, 6)
    ]
    shd_hole_pts2 = [
        Point3D(5, 5, 6),
        Point3D(7, 5, 6),
        Point3D(7, 7, 6),
        Point3D(5, 7, 6)
    ]
    s_face = Face3D(shd_bound_pts, None, [shd_hole_pts1, shd_hole_pts2])
    shd = Shade('Canopy', s_face)

    model = Model('Donut_Building', [room], orphaned_shades=[shd])

    dest_file = os.path.join(directory, 'model_complete_holes.json')
    with open(dest_file, 'w') as fp:
        json.dump(model.to_dict(), fp, indent=4)