Ejemplo n.º 1
0
def aperture_state_abridged_electrochromic(directory):
    ecglass4 = Glass.from_single_transmittance('ElectrochromicGlass4', 0.01)
    tint4 = RadianceSubFaceState(ecglass4)

    dest_file = os.path.join(directory, 'aperture_state_abridged_electrochromic.json')
    with open(dest_file, 'w') as fp:
        json.dump(tint4.to_dict(abridged=True), fp, indent=4)
Ejemplo n.º 2
0
def test_to_from_dict_with_states():
    """Test the Door from_dict method with radiance properties."""
    dr = Door.from_vertices('front_door',
                            [[0, 0, 0], [10, 0, 0], [10, 0, 10], [0, 0, 10]])
    shd1 = StateGeometry.from_vertices(
        'wall_overhang1', [[0, 0, 10], [10, 0, 10], [10, 2, 10], [0, 2, 10]])
    shd2 = StateGeometry.from_vertices(
        'wall_overhang2', [[0, 0, 5], [10, 0, 5], [10, 2, 5], [0, 2, 5]])

    ecglass1 = Glass.from_single_transmittance('ElectrochromicState1', 0.4)
    ecglass2 = Glass.from_single_transmittance('ElectrochromicState2', 0.27)
    ecglass3 = Glass.from_single_transmittance('ElectrochromicState3', 0.14)
    ecglass4 = Glass.from_single_transmittance('ElectrochromicState4', 0.01)

    tint1 = RadianceSubFaceState(ecglass1)
    tint2 = RadianceSubFaceState(ecglass2)
    tint3 = RadianceSubFaceState(ecglass3, [shd1])
    tint4 = RadianceSubFaceState(ecglass4, [shd1.duplicate(), shd2])
    states = (tint1, tint2, tint3, tint4)

    dr.properties.radiance.dynamic_group_identifier = 'ElectrochromicDoor1'
    dr.properties.radiance.states = states

    drd = dr.to_dict()
    new_door = Door.from_dict(drd)
    assert new_door.properties.radiance.dynamic_group_identifier == \
        dr.properties.radiance.dynamic_group_identifier
    state_ids1 = [state.modifier for state in states]
    state_ids2 = [
        state.modifier for state in new_door.properties.radiance.states
    ]
    assert state_ids1 == state_ids2
    assert new_door.to_dict() == drd
Ejemplo n.º 3
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 = Aperture('TestWindow', 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 = RadianceSubFaceState(shades=[shade])
    ap.properties.radiance.dynamic_group_identifier = 'ElectrochromicWindow1'
    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)
Ejemplo n.º 4
0
def aperture_state_abridged_bsdf(directory):
    relative_path = './scripts/bsdf/klemsfull.xml'
    mod = BSDF(relative_path)
    shd_state = RadianceSubFaceState(mod)

    pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(1, 0, 3), Point3D(1, 0, 0))
    ap = Aperture('TestWindow', Face3D(pts))
    ap.properties.radiance.dynamic_group_identifier = 'DynamicShdWindow'
    ap.properties.radiance.states = [shd_state]
    shd_state.gen_geos_from_tmtx_thickness(0.05)

    dest_file = os.path.join(directory, 'aperture_state_abridged_bsdf.json')
    with open(dest_file, 'w') as fp:
        json.dump(shd_state.to_dict(abridged=True), fp, indent=4)
Ejemplo n.º 5
0
def aperture_state_abridged_shades(directory):
    mod = Trans('DiffusingShade', 0.7, 0.7, 0.7, 0.01, 0, 0.45, 0.01)
    mod_dir = Glass.from_single_transmittance('DiffusingShadeDirect', 0.03)
    mod_shd = Plastic('ShadeMat', 0.65, 0.65, 0.65)
    pts_1 = (Point3D(0, 0, 0), Point3D(2, 0, 0), Point3D(2, 2, 0), Point3D(0, 2, 0))
    pts_2 = (Point3D(0, 0, 2), Point3D(2, 0, 0), Point3D(2, 2, 2), Point3D(0, 2, 2))
    shade1 = StateGeometry('RectangleShade1', Face3D(pts_1))
    shade2 = StateGeometry('RectangleShade2', Face3D(pts_2))
    shade1.modifier = mod_shd
    shade2.modifier = mod_shd
    rad_state = RadianceSubFaceState(mod, [shade1, shade2])
    rad_state.modifier_direct = mod_dir

    dest_file = os.path.join(directory, 'aperture_state_abridged_shades.json')
    with open(dest_file, 'w') as fp:
        json.dump(rad_state.to_dict(abridged=True), fp, indent=4)
Ejemplo n.º 6
0
def test_to_from_dict_with_states():
    """Test the Aperture from_dict method with radiance properties."""
    ap = Aperture.from_vertices(
        'wall_aperture', [[0, 0, 0], [10, 0, 0], [10, 0, 10], [0, 0, 10]])
    shd1 = StateGeometry.from_vertices(
        'wall_overhang1', [[0, 0, 10], [10, 0, 10], [10, 2, 10], [0, 2, 10]])
    shd2 = StateGeometry.from_vertices(
        'wall_overhang2', [[0, 0, 5], [10, 0, 5], [10, 2, 5], [0, 2, 5]])

    ecglass1 = Glass.from_single_transmittance('ElectrochromicState1', 0.4)
    ecglass2 = Glass.from_single_transmittance('ElectrochromicState2', 0.27)
    ecglass3 = Glass.from_single_transmittance('ElectrochromicState3', 0.14)
    ecglass4 = Glass.from_single_transmittance('ElectrochromicState4', 0.01)

    tint1 = RadianceSubFaceState(ecglass1)
    tint2 = RadianceSubFaceState(ecglass2)
    tint3 = RadianceSubFaceState(ecglass3, [shd1])
    tint4 = RadianceSubFaceState(ecglass4, [shd1.duplicate(), shd2])
    states = (tint1, tint2, tint3, tint4)

    ap.properties.radiance.dynamic_group_identifier = 'ElectrochromicWindow1'
    ap.properties.radiance.states = states
    tint4.gen_geos_from_tmtx_thickness(0.05)

    ad = ap.to_dict()
    new_aperture = Aperture.from_dict(ad)
    assert new_aperture.properties.radiance.dynamic_group_identifier == \
        ap.properties.radiance.dynamic_group_identifier
    state_ids1 = [state.modifier for state in states]
    state_ids2 = [
        state.modifier for state in new_aperture.properties.radiance.states
    ]
    assert state_ids1 == state_ids2
    assert new_aperture.to_dict() == ad
Ejemplo n.º 7
0
def move_state_shades():
    """Check to be sure that dynamic shades are moved with their parent."""
    pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(1, 0,
                                                       3), Point3D(1, 0, 0))
    ap = Aperture('TestWindow', 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 = RadianceSubFaceState(shades=[shade])
    ap.properties.radiance.dynamic_group_identifier = 'ElectrochromicWindow1'
    ap.properties.radiance.states = [tint1]
    tint1.gen_geos_from_tmtx_thickness(0.05)

    vec_1 = Vector3D(2, 2, 2)
    new_ap = ap.duplicate()
    new_ap.move(vec_1)
    new_shd = new_ap.properties.radiance.states[0].shades[0]
    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)
Ejemplo n.º 8
0
def scale_state_shades():
    """Check to be sure that dynamic shades are scaled with their parent."""
    pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2,
                                                       2), Point3D(1, 2, 2))
    ap = Aperture('TestWindow', 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 = RadianceSubFaceState(shades=[shade])
    ap.properties.radiance.dynamic_group_identifier = 'ElectrochromicWindow1'
    ap.properties.radiance.states = [tint1]
    tint1.gen_geo_from_vmtx_offset(0.05)
    tint1.gen_geo_from_dmtx_offset(0.1)

    new_ap = ap.duplicate()
    new_ap.scale(2)
    new_shd = new_ap.properties.radiance.states[0].shades[0]
    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)
"""
Create a State object representing a single dynamic group state.
-

    Args:
        modifier_: A Honeybee Radiance Modifier object to be applied to this state's
            parent in this state. This is used to swap out the modifier in
            multi-phase studies. If None, it will be the parent's default modifier.
        shades_: An optional array of StateGeometry objects to be included
            with this state.
    
    Returns:
        state: A Honeybee State object representing a single dynamic group state.
            This can be assigned to apertures or shades using the "HB Dynamic
            Aperture Group" componet or the "HB Dynamic Shade Group" component.
"""

ghenv.Component.Name = 'HB Dynamic State'
ghenv.Component.NickName = 'State'
ghenv.Component.Message = '1.1.0'
ghenv.Component.Category = 'HB-Radiance'
ghenv.Component.SubCategory = '0 :: Basic Properties'
ghenv.Component.AdditionalHelpFromDocStrings = '3'

try:
    from honeybee_radiance.dynamic import RadianceSubFaceState
except ImportError as e:
    raise ImportError('\nFailed to import honeybee_radiance:\n\t{}'.format(e))

state = RadianceSubFaceState(modifier_, [geo.duplicate() for geo in shades_])
Ejemplo n.º 10
0
def model_radiance_dynamic_states(directory):
    room = Room.from_box('Tiny_House_Zone', 5, 10, 3)
    garage = Room.from_box('Tiny_Garage', 5, 10, 3, origin=Point3D(5, 0, 0))

    south_face = room[3]
    south_face.apertures_by_ratio(0.5, 0.01)
    shd1 = StateGeometry.from_vertices(
        'outdoor_awning', [[0, 0, 2], [5, 0, 2], [5, 2, 2], [0, 2, 2]])

    ecglass1 = Glass.from_single_transmittance('ElectrochromicState1', 0.4)
    ecglass2 = Glass.from_single_transmittance('ElectrochromicState2', 0.27)
    ecglass3 = Glass.from_single_transmittance('ElectrochromicState3', 0.14)
    ecglass4 = Glass.from_single_transmittance('ElectrochromicState4', 0.01)

    tint1 = RadianceSubFaceState(ecglass1)
    tint2 = RadianceSubFaceState(ecglass2)
    tint3 = RadianceSubFaceState(ecglass3, [shd1])
    tint4 = RadianceSubFaceState(ecglass4, [shd1.duplicate()])
    states = (tint1, tint2, tint3, tint4)
    south_face.apertures[0].properties.radiance.dynamic_group_identifier = \
        'ElectrochromicWindow'
    south_face.apertures[0].properties.radiance.states = states

    shd2 = Shade.from_vertices('indoor_light_shelf',
                               [[0, 0, 2], [-1, 0, 2], [-1, 2, 2], [0, 2, 2]])
    ref_1 = Plastic.from_single_reflectance('outdoor_light_shelf_0.5', 0.5)
    ref_2 = Plastic.from_single_reflectance('indoor_light_shelf_0.70', 0.7)
    light_shelf_1 = RadianceShadeState(ref_1)
    light_shelf_2 = RadianceShadeState(ref_2)
    shelf_states = (light_shelf_1, light_shelf_2)
    shd2.properties.radiance.dynamic_group_identifier = 'DynamicLightShelf'
    shd2.properties.radiance.states = shelf_states
    room.add_indoor_shade(shd2)

    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)
    sum_tree_trans = Trans.from_single_reflectance('SummerLeaves', 0.3, 0.0,
                                                   0.1, 0.15, 0.15)
    win_tree_trans = Trans.from_single_reflectance('WinterLeaves', 0.1, 0.0,
                                                   0.1, 0.1, 0.6)
    summer = RadianceShadeState(sum_tree_trans)
    winter = RadianceShadeState(win_tree_trans)
    tree_canopy.properties.radiance.dynamic_group_identifier = 'DeciduousTree'
    tree_canopy.properties.radiance.states = (summer, winter)

    ground_geo = Face3D.from_rectangle(10, 10, Plane(o=Point3D(0, -10, 0)))
    ground = Shade('Ground', ground_geo)
    grass = Plastic.from_single_reflectance('grass', 0.3)
    snow = Plastic.from_single_reflectance('snow', 0.7)
    summer_ground = RadianceShadeState(grass)
    winter_ground = RadianceShadeState(snow)
    ground.properties.radiance.dynamic_group_identifier = 'SeasonalGround'
    ground.properties.radiance.states = (summer_ground, winter_ground)

    east_face = room[2]
    east_face.apertures_by_ratio(0.1, 0.01)
    west_face = garage[4]
    west_face.apertures_by_ratio(0.1, 0.01)
    Room.solve_adjacency([room, garage], 0.01)

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

    model_dict = model.to_dict(included_prop=['radiance'])

    dest_file = os.path.join(directory, 'model_radiance_dynamic_states.json')
    with open(dest_file, 'w') as fp:
        json.dump(model_dict, fp, indent=4)
Ejemplo n.º 11
0
def test_writer_to_rad_folder_shade_drop():
    """Test the Model to.rad_folder method with shades that drop half-way."""
    room = Room.from_box('Store_Entrance', 10, 10, 6)

    # create the apertures on the south side and put them in the same dynamic group
    pts_1 = [Point3D(1, 0, 1), Point3D(4, 0, 1), Point3D(4, 0, 3), Point3D(1, 0, 3)]
    pts_2 = [Point3D(1, 0, 3), Point3D(4, 0, 3), Point3D(4, 0, 5), Point3D(1, 0, 5)]
    pts_3 = [Point3D(6, 0, 1), Point3D(9, 0, 1), Point3D(9, 0, 3), Point3D(6, 0, 3)]
    pts_4 = [Point3D(6, 0, 3), Point3D(9, 0, 3), Point3D(9, 0, 5), Point3D(6, 0, 5)]
    pts_5 = [Point3D(4.5, 0, 0.25), Point3D(5.5, 0, 0.25), Point3D(5.5, 0, 5), Point3D(4.5, 0, 5)]
    s_left_bottom = Aperture('s_left_bottom', Face3D(pts_1))
    s_left_top = Aperture('s_left_top', Face3D(pts_2))
    s_right_bottom = Aperture('s_right_bottom', Face3D(pts_3))
    s_right_top = Aperture('s_right_top', Face3D(pts_4))
    entry = Aperture('entry', Face3D(pts_5))
    south_face = room[3]
    south_apertures = [s_left_bottom, s_left_top, s_right_bottom, s_right_top, entry]
    south_face.add_apertures(south_apertures)
    for ap in south_apertures:
        ap.properties.radiance.dynamic_group_identifier = 'SouthWall'

    # create the apertures on the east side and put them in the same dynamic group
    pts_6 = [Point3D(10, 1, 1), Point3D(10, 9, 1), Point3D(10, 9, 3), Point3D(10, 1, 3)]
    pts_7 = [Point3D(10, 1, 3), Point3D(10, 9, 3), Point3D(10, 9, 5), Point3D(10, 1, 5)]
    e_bottom = Aperture('e_bottom', Face3D(pts_6))
    e_top = Aperture('e_top', Face3D(pts_7))
    east_face = room[2]
    east_apertures = [e_bottom, e_top]
    east_face.add_apertures(east_apertures)
    for ap in east_apertures:
        ap.properties.radiance.dynamic_group_identifier = 'EastWall'

    # create the states
    bare_glass = Glass.from_single_transmittance('BareGlass', 0.7)
    protected_glass = Glass.from_single_transmittance('ProtectedGlass', 0.3)
    bare = RadianceSubFaceState(bare_glass)
    protected = RadianceSubFaceState(protected_glass)

    # assign states to individual apertures
    s_left_bottom.properties.radiance.states = \
        [bare.duplicate(), bare.duplicate(), protected.duplicate()]
    s_right_bottom.properties.radiance.states = \
        [bare.duplicate(), bare.duplicate(), protected.duplicate()]
    s_left_top.properties.radiance.states = \
        [bare.duplicate(), protected.duplicate(), protected.duplicate()]
    s_right_top.properties.radiance.states = \
        [bare.duplicate(), protected.duplicate(), protected.duplicate()]
    entry.properties.radiance.modifier = bare_glass

    e_bottom.properties.radiance.states = \
        [bare.duplicate(), bare.duplicate(), protected.duplicate()]
    e_top.properties.radiance.states = \
        [bare.duplicate(), protected.duplicate(), protected.duplicate()]

    # export the model radiance folder
    model = Model('Apple_Store', [room])
    folder = os.path.abspath('./tests/assets/model/rad_folder_shade_drop')
    model.to.rad_folder(model, folder)

    model_folder = ModelFolder(folder)

    ap_dir = model_folder.aperture_group_folder(full=True)
    assert os.path.isfile(os.path.join(ap_dir, 'states.json'))

    group_name = entry.properties.radiance.dynamic_group_identifier
    assert os.path.isfile(os.path.join(ap_dir, '{}..black.rad'.format(group_name)))
    for i in range(len(entry.properties.radiance.states)):
        d_file = (os.path.join(ap_dir, '{}..default..{}.rad'.format(group_name, i)))
        assert os.path.isfile(d_file)
    for i in range(len(entry.properties.radiance.states)):
        d_file = (os.path.join(ap_dir, '{}..direct..{}.rad'.format(group_name, i)))
        assert os.path.isfile(d_file)

    group_name = e_bottom.properties.radiance.dynamic_group_identifier
    assert os.path.isfile(os.path.join(ap_dir, '{}..black.rad'.format(group_name)))
    for i in range(len(e_bottom.properties.radiance.states)):
        d_file = (os.path.join(ap_dir, '{}..default..{}.rad'.format(group_name, i)))
        assert os.path.isfile(d_file)
    for i in range(len(e_bottom.properties.radiance.states)):
        d_file = (os.path.join(ap_dir, '{}..direct..{}.rad'.format(group_name, i)))
        assert os.path.isfile(d_file)

    # clean up the folder
    nukedir(folder, rmdir=True)
Ejemplo n.º 12
0
def test_writer_to_rad_folder_multiphase():
    """Test the Model to.rad_folder method with multi-phase objects like BSDFs."""
    room = Room.from_box('Tiny_House_Zone', 5, 10, 3)
    south_face = room[3]
    south_face.apertures_by_ratio(0.5, 0.01)
    south_aperture = south_face.apertures[0]
    north_face = room[1]
    north_face.apertures_by_ratio(0.5, 0.01)
    north_aperture = north_face.apertures[0]

    folder = os.path.abspath('./tests/assets/')
    clear_bsdf = BSDF(os.path.join(folder, 'clear.xml'))
    diff_bsdf = BSDF(os.path.join(folder, 'diffuse50.xml'))
    clear = RadianceSubFaceState(clear_bsdf)
    diffuse = RadianceSubFaceState(diff_bsdf)

    south_aperture.properties.radiance.dynamic_group_identifier = 'SouthDynamicWindow'
    south_aperture.properties.radiance.states = [clear, diffuse]
    north_aperture.properties.radiance.dynamic_group_identifier = 'NorthDynamicWindow'
    north_aperture.properties.radiance.states = [clear.duplicate(), diffuse.duplicate()]
    north_aperture.properties.radiance.states[0].gen_geos_from_tmtx_thickness(0.1)
    north_aperture.properties.radiance.states[1].gen_geos_from_tmtx_thickness(0.2)

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

    folder = os.path.abspath('./tests/assets/model/rad_folder_multiphase')
    model.to.rad_folder(model, folder)

    model_folder = ModelFolder(folder)

    bsdf_dir = model_folder.bsdf_folder(full=True)
    assert os.path.isfile(os.path.join(bsdf_dir, 'clear.xml'))
    assert os.path.isfile(os.path.join(bsdf_dir, 'diffuse50.xml'))

    ap_dir = model_folder.aperture_group_folder(full=True)
    assert os.path.isfile(os.path.join(ap_dir, 'states.json'))

    group_name = south_aperture.properties.radiance.dynamic_group_identifier
    assert os.path.isfile(os.path.join(ap_dir, '{}..black.rad'.format(group_name)))
    assert os.path.isfile(os.path.join(ap_dir, '{}..mtx.rad'.format(group_name)))
    for i in range(len(south_aperture.properties.radiance.states)):
        d_file = (os.path.join(ap_dir, '{}..default..{}.rad'.format(group_name, i)))
        assert os.path.isfile(d_file)
    for i in range(len(south_aperture.properties.radiance.states)):
        d_file = (os.path.join(ap_dir, '{}..direct..{}.rad'.format(group_name, i)))
        assert os.path.isfile(d_file)

    group_name = north_aperture.properties.radiance.dynamic_group_identifier
    assert os.path.isfile(os.path.join(ap_dir, '{}..black.rad'.format(group_name)))
    for i in range(len(north_aperture.properties.radiance.states)):
        d_file = (os.path.join(ap_dir, '{}..default..{}.rad'.format(group_name, i)))
        assert os.path.isfile(d_file)
    for i in range(len(north_aperture.properties.radiance.states)):
        d_file = (os.path.join(ap_dir, '{}..direct..{}.rad'.format(group_name, i)))
        assert os.path.isfile(d_file)
    for i in range(len(north_aperture.properties.radiance.states)):
        d_file = (os.path.join(ap_dir, '{}..dmtx..{}.rad'.format(group_name, i)))
        assert os.path.isfile(d_file)
    for i in range(len(north_aperture.properties.radiance.states)):
        d_file = (os.path.join(ap_dir, '{}..vmtx..{}.rad'.format(group_name, i)))
        assert os.path.isfile(d_file)

    # clean up the folder
    nukedir(folder, rmdir=True)
Ejemplo n.º 13
0
def test_writer_to_rad_folder_dynamic():
    """Test the Model to.rad_folder method with dynamic geometry."""
    room = Room.from_box('Tiny_House_Zone', 5, 10, 3)
    garage = Room.from_box('Tiny_Garage', 5, 10, 3, origin=Point3D(5, 0, 0))

    south_face = room[3]
    south_face.apertures_by_ratio(0.5, 0.01)
    shd1 = StateGeometry.from_vertices(
        'outdoor_awning', [[0, 0, 2], [5, 0, 2], [5, 2, 2], [0, 2, 2]])

    ecglass1 = Glass.from_single_transmittance('ElectrochromicState1', 0.4)
    ecglass2 = Glass.from_single_transmittance('ElectrochromicState2', 0.27)
    ecglass3 = Glass.from_single_transmittance('ElectrochromicState3', 0.14)
    ecglass4 = Glass.from_single_transmittance('ElectrochromicState4', 0.01)

    tint1 = RadianceSubFaceState(ecglass1)
    tint2 = RadianceSubFaceState(ecglass2)
    tint3 = RadianceSubFaceState(ecglass3, [shd1])
    tint4 = RadianceSubFaceState(ecglass4, [shd1.duplicate()])
    states = (tint1, tint2, tint3, tint4)
    south_face.apertures[0].properties.radiance.dynamic_group_identifier = \
        'ElectrochromicWindow'
    south_face.apertures[0].properties.radiance.states = states

    shd2 = Shade.from_vertices(
        'indoor_light_shelf', [[0, 0, 2], [-1, 0, 2], [-1, 2, 2], [0, 2, 2]])
    ref_1 = Plastic.from_single_reflectance('outdoor_light_shelf_0.5', 0.5)
    ref_2 = Plastic.from_single_reflectance('indoor_light_shelf_0.70', 0.7)
    light_shelf_1 = RadianceShadeState(ref_1)
    light_shelf_2 = RadianceShadeState(ref_2)
    shelf_states = (light_shelf_1, light_shelf_2)
    shd2.properties.radiance.dynamic_group_identifier = 'DynamicLightShelf'
    shd2.properties.radiance.states = shelf_states
    room.add_indoor_shade(shd2)

    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)
    sum_tree_trans = Trans.from_single_reflectance('SummerLeaves', 0.3, 0.0, 0.1, 0.15, 0.15)
    win_tree_trans = Trans.from_single_reflectance('WinterLeaves', 0.1, 0.0, 0.1, 0.1, 0.6)
    summer = RadianceShadeState(sum_tree_trans)
    winter = RadianceShadeState(win_tree_trans)
    tree_canopy.properties.radiance.dynamic_group_identifier = 'DeciduousTree'
    tree_canopy.properties.radiance.states = (summer, winter)

    ground_geo = Face3D.from_rectangle(10, 10, Plane(o=Point3D(0, -10, 0)))
    ground = Shade('Ground', ground_geo)
    grass = Plastic.from_single_reflectance('grass', 0.3)
    snow = Plastic.from_single_reflectance('snow', 0.7)
    summer_ground = RadianceShadeState(grass)
    winter_ground = RadianceShadeState(snow)
    ground.properties.radiance.dynamic_group_identifier = 'SeasonalGround'
    ground.properties.radiance.states = (summer_ground, winter_ground)

    east_face = room[2]
    east_face.apertures_by_ratio(0.1, 0.01)
    west_face = garage[4]
    west_face.apertures_by_ratio(0.1, 0.01)
    Room.solve_adjacency([room, garage], 0.01)

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

    folder = os.path.abspath('./tests/assets/model/rad_folder_dynamic')
    model.to.rad_folder(model, folder)

    model_folder = ModelFolder(folder)

    ap_dir = model_folder.aperture_group_folder(full=True)
    assert os.path.isfile(os.path.join(ap_dir, 'states.json'))
    group_name = south_face.apertures[0].properties.radiance.dynamic_group_identifier
    assert os.path.isfile(os.path.join(ap_dir, '{}..black.rad'.format(group_name)))
    for i in range(len(south_face.apertures[0].properties.radiance.states)):
        d_file = (os.path.join(ap_dir, '{}..default..{}.rad'.format(group_name, i)))
        assert os.path.isfile(d_file)
    for i in range(len(south_face.apertures[0].properties.radiance.states)):
        d_file = (os.path.join(ap_dir, '{}..direct..{}.rad'.format(group_name, i)))
        assert os.path.isfile(d_file)

    out_scene_dir = model_folder.dynamic_scene_folder(full=True, indoor=False)
    assert os.path.isfile(os.path.join(out_scene_dir, 'states.json'))
    grp_name = tree_canopy.properties.radiance.dynamic_group_identifier
    for i in range(len(tree_canopy.properties.radiance.states)):
        d_file = (os.path.join(out_scene_dir, '{}..default..{}.rad'.format(grp_name, i)))
        assert os.path.isfile(d_file)
    for i in range(len(tree_canopy.properties.radiance.states)):
        d_file = (os.path.join(out_scene_dir, '{}..direct..{}.rad'.format(grp_name, i)))
        assert os.path.isfile(d_file)
    grp_name = ground.properties.radiance.dynamic_group_identifier
    for i in range(len(ground.properties.radiance.states)):
        d_file = (os.path.join(out_scene_dir, '{}..default..{}.rad'.format(grp_name, i)))
        assert os.path.isfile(d_file)
    for i in range(len(ground.properties.radiance.states)):
        d_file = (os.path.join(out_scene_dir, '{}..direct..{}.rad'.format(grp_name, i)))
        d_file = (os.path.join(out_scene_dir, '{}..direct..{}.rad'.format(grp_name, i)))
        assert os.path.isfile(d_file)

    in_scene_dir = model_folder.dynamic_scene_folder(full=True, indoor=True)
    assert os.path.isfile(os.path.join(in_scene_dir, 'states.json'))
    grp_name = shd2.properties.radiance.dynamic_group_identifier
    for i in range(len(shd2.properties.radiance.states)):
        d_file = (os.path.join(in_scene_dir, '{}..default..{}.rad'.format(grp_name, i)))
        assert os.path.isfile(d_file)
    for i in range(len(shd2.properties.radiance.states)):
        d_file = (os.path.join(in_scene_dir, '{}..direct..{}.rad'.format(grp_name, i)))
        assert os.path.isfile(d_file)

    # clean up the folder
    nukedir(folder, rmdir=True)
Ejemplo n.º 14
0
def test_set_states():
    """Test the setting of states on an Aperture."""
    pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(1, 0,
                                                       3), Point3D(1, 0, 0))
    ap = Aperture('TestWindow', Face3D(pts))
    shd1 = StateGeometry.from_vertices(
        'wall_overhang1', [[0, 0, 10], [10, 0, 10], [10, 2, 10], [0, 2, 10]])
    shd2 = StateGeometry.from_vertices(
        'wall_overhang2', [[0, 0, 5], [10, 0, 5], [10, 2, 5], [0, 2, 5]])

    ecglass1 = Glass.from_single_transmittance('ElectrochromicState1', 0.4)
    ecglass2 = Glass.from_single_transmittance('ElectrochromicState2', 0.27)
    ecglass3 = Glass.from_single_transmittance('ElectrochromicState3', 0.14)
    ecglass4 = Glass.from_single_transmittance('ElectrochromicState4', 0.01)

    tint1 = RadianceSubFaceState(ecglass1)
    tint2 = RadianceSubFaceState(ecglass2)
    tint3 = RadianceSubFaceState(ecglass3)
    tint4 = RadianceSubFaceState(ecglass4)
    states = (tint1, tint2, tint3, tint4)

    tint3.add_shade(shd1)
    with pytest.raises(AssertionError):
        tint4.add_shades([shd1, shd2])
    tint4.add_shades([shd1.duplicate(), shd2])

    with pytest.raises(AssertionError):
        tint1.gen_geos_from_tmtx_thickness(0.05)
    with pytest.raises(AssertionError):
        tint1.gen_geo_from_vmtx_offset(0.1)
    with pytest.raises(AssertionError):
        tint1.gen_geo_from_dmtx_offset(0.1)

    with pytest.raises(AssertionError):
        ap.properties.radiance.states = states
    ap.properties.radiance.dynamic_group_identifier = 'ElectrochromicWindow1'
    ap.properties.radiance.states = states

    for state in ap.properties.radiance.states:
        assert state.parent.identifier == 'TestWindow'

    new_ap = ap.duplicate()

    assert ap.properties.radiance.dynamic_group_identifier == \
        new_ap.properties.radiance.dynamic_group_identifier == 'ElectrochromicWindow1'
    assert len(new_ap.properties.radiance.states) == 4
    for i, state in enumerate(new_ap.properties.radiance.states):
        assert state.modifier.identifier == 'ElectrochromicState{}'.format(i +
                                                                           1)
    assert len(new_ap.properties.radiance.states[2].shades) == 1
    assert len(new_ap.properties.radiance.states[3].shades) == 2