Exemplo n.º 1
0
 def to_radiance_visible(self):
     """Honeybee Radiance material with the visible transmittance."""
     try:
         from honeybee_radiance.modifier.material import Glass
         from honeybee_radiance.modifier.material import Trans
     except ImportError as e:
         raise ImportError(
             'honeybee_radiance library must be installed to use '
             'to_radiance_visible() method. {}'.format(e))
     diffusing = False
     trans = 1
     for mat in self.materials:
         if isinstance(mat, EnergyWindowMaterialSimpleGlazSys):
             trans *= mat.vt
         elif isinstance(mat, EnergyWindowMaterialGlazing):
             trans *= mat.visible_transmittance
             diffusing = True if mat.solar_diffusing is True else False
     if not diffusing:
         return Glass.from_single_transmittance(
             clean_rad_string(self.identifier), trans)
     else:
         try:
             ref = self.materials[-1].solar_reflectance_back
         except AttributeError:
             ref = self.materials[-1].solar_reflectance
         return Trans.from_single_reflectance(clean_rad_string(
             self.identifier),
                                              rgb_reflectance=ref,
                                              transmitted_diff=trans,
                                              transmitted_spec=0)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
0
def test_writer_to_rad_folder():
    """Test the Model to.rad_folder method."""
    room = Room.from_box('Tiny_House_Zone', 5, 10, 3)
    garage = Room.from_box('Tiny_Garage', 5, 10, 3, origin=Point3D(5, 0, 0))

    dark_floor = Plastic.from_single_reflectance('DarkFloor', 0.1)
    room[0].properties.radiance.modifier = dark_floor
    room[5].properties.radiance.modifier_blk = 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)
    tree_trans = Trans.from_single_reflectance('Leaves', 0.3, 0.0, 0.1, 0.15, 0.15)
    tree_canopy.properties.radiance.modifier = tree_trans

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

    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=[tree_canopy])

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

    model_folder = ModelFolder(folder)

    ap_dir = model_folder.aperture_folder(full=True)
    assert os.path.isfile(os.path.join(ap_dir, 'aperture.rad'))
    assert os.path.isfile(os.path.join(ap_dir, 'aperture.mat'))
    assert os.path.isfile(os.path.join(ap_dir, 'aperture.blk'))

    scene_dir = model_folder.scene_folder(full=True)
    assert os.path.isfile(os.path.join(scene_dir, 'envelope.rad'))
    assert os.path.isfile(os.path.join(scene_dir, 'envelope.mat'))
    assert os.path.isfile(os.path.join(scene_dir, 'envelope.blk'))
    assert os.path.isfile(os.path.join(scene_dir, 'shades.rad'))
    assert os.path.isfile(os.path.join(scene_dir, 'shades.mat'))
    assert os.path.isfile(os.path.join(scene_dir, 'shades.blk'))

    # clean up the folder
    nukedir(folder, rmdir=True)
Exemplo n.º 5
0
def test_from_single_value():
    tr = Trans.from_single_reflectance('test', 0.6)
    assert tr.r_reflectance == 0.6
    assert tr.g_reflectance == 0.6
    assert tr.b_reflectance == 0.6
Exemplo n.º 6
0
def modifier_trans_tree_foliage(directory):
    tree_leaves = Trans.from_single_reflectance('Foliage_0.3', 0.3, 0.0, 0.1,
                                                0.15, 0.15)
    dest_file = os.path.join(directory, 'modifier_trans_tree_foliage.json')
    with open(dest_file, 'w') as fp:
        json.dump(tree_leaves.to_dict(), fp, indent=4)
ghenv.Component.Category = 'HB-Radiance'
ghenv.Component.SubCategory = '1 :: Modifiers'
ghenv.Component.AdditionalHelpFromDocStrings = '2'

try:  # import the core honeybee dependencies
    from honeybee.typing import clean_and_id_rad_string
except ImportError as e:
    raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))

try:  # import the honeybee-radiance dependencies
    from honeybee_radiance.modifier.material import Trans
except ImportError as e:
    raise ImportError('\nFailed to import honeybee_radiance:\n\t{}'.format(e))

try:  # import ladybug_rhino dependencies
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))


if all_required_inputs(ghenv.Component):
    # set the default modifier properties
    _spec_ = 0.0 if _spec_ is None else _spec_
    _rough_ = 0.0 if _rough_ is None else _rough_

    # create the modifier
    modifier = Trans.from_single_reflectance(
        clean_and_id_rad_string(_name), _diff_ref, _spec_, _rough_,
        _diff_trans, _spec_trans)
    modifier.display_name = _name