Пример #1
0
def test_dict_to_object_win_par():
    """Test the dict_to_object method with window parameters."""
    simple_window = SingleWindow(5, 2, 0.8)
    ashrae_base1 = SimpleWindowRatio(0.4)
    ashrae_base2 = RepeatingWindowRatio(0.4, 2, 0.8, 3)
    bod_windows = RepeatingWindowWidthHeight(2, 1.5, 0.8, 3)

    origins = (Point2D(2, 1), Point2D(5, 0.5))
    widths = (1, 3)
    heights = (1, 2)
    detailed_window1 = RectangularWindows(origins, widths, heights)

    pts_1 = (Point2D(2, 1), Point2D(3, 1), Point2D(3, 2), Point2D(2, 2))
    pts_2 = (Point2D(5, 0.5), Point2D(8, 0.5), Point2D(8,
                                                       2.5), Point2D(5, 2.5))
    detailed_window2 = DetailedWindows((Polygon2D(pts_1), Polygon2D(pts_2)))

    assert isinstance(dict_to_object(simple_window.to_dict()), SingleWindow)
    assert isinstance(dict_to_object(ashrae_base1.to_dict()),
                      SimpleWindowRatio)
    assert isinstance(dict_to_object(ashrae_base2.to_dict()),
                      RepeatingWindowRatio)
    assert isinstance(dict_to_object(bod_windows.to_dict()),
                      RepeatingWindowWidthHeight)
    assert isinstance(dict_to_object(detailed_window1.to_dict()),
                      RectangularWindows)
    assert isinstance(dict_to_object(detailed_window2.to_dict()),
                      DetailedWindows)
Пример #2
0
def window_par_repeating_window_ratio(directory):
    ashrae_base = RepeatingWindowRatio(0.4, 2, 0.8, 3)

    dest_file = os.path.join(directory,
                             'window_par_repeating_window_ratio.json')
    with open(dest_file, 'w') as fp:
        json.dump(ashrae_base.to_dict(), fp, indent=4)
def test_repeating_window_ratio_dict_methods():
    """Test the to/from dict methods."""
    ashrae_base = RepeatingWindowRatio(0.4, 2, 0.8, 3)

    glz_dict = ashrae_base.to_dict()
    new_ashrae_base = RepeatingWindowRatio.from_dict(glz_dict)
    assert new_ashrae_base == ashrae_base
    assert glz_dict == new_ashrae_base.to_dict()
def test_repeating_window_ratio_scale():
    """Test the scale method."""
    ashrae_base = RepeatingWindowRatio(0.4, 2, 0.8, 3)

    new_ashrae_base  = ashrae_base.scale(2)
    assert new_ashrae_base.window_ratio == ashrae_base.window_ratio
    assert new_ashrae_base.window_height == 4
    assert new_ashrae_base.sill_height == 1.6
    assert new_ashrae_base.horizontal_separation == 6
def test_repeating_window_ratio_equality():
    """Test the equality of RepeatingWindowRatio objects."""
    ashrae_base = RepeatingWindowRatio(0.4, 2, 0.8, 3)
    ashrae_base_dup = ashrae_base.duplicate()
    ashrae_base_alt = RepeatingWindowRatio(0.25, 2, 0.8, 3)

    assert ashrae_base is ashrae_base
    assert ashrae_base is not ashrae_base_dup
    assert ashrae_base == ashrae_base_dup
    assert hash(ashrae_base) == hash(ashrae_base_dup)
    assert ashrae_base != ashrae_base_alt
    assert hash(ashrae_base) != hash(ashrae_base_alt)
def test_repeating_window_ratio_add_window_to_face():
    """Test the add_window_to_face method."""
    ashrae_base = RepeatingWindowRatio(0.4, 2, 0.8, 3)
    height = 3
    width = 10
    seg = LineSegment3D.from_end_points(Point3D(0, 0, 2), Point3D(width, 0, 2))
    face = Face('test_face', Face3D.from_extrusion(seg, Vector3D(0, 0, height)))
    ashrae_base.add_window_to_face(face, 0.01)

    assert len(face.apertures) == 3
    ap_area = sum([ap.area for ap in face.apertures])
    assert ashrae_base.area_from_segment(seg, height) == \
        pytest.approx(ap_area, rel=1e-3) == width * height * 0.4
def test_repeating_window_ratio_init():
    """Test the initalization of RepeatingWindowRatio objects and basic properties."""
    ashrae_base = RepeatingWindowRatio(0.4, 2, 0.8, 3)
    str(ashrae_base)  # test the string representation

    assert ashrae_base.window_ratio == 0.4
    assert ashrae_base.window_height == 2
    assert ashrae_base.sill_height == 0.8
    assert ashrae_base.horizontal_separation == 3
    assert ashrae_base.vertical_separation == 0
Пример #8
0
def lab_building(directory):
    poly_file = './scripts/geometry/lab_building_geo.json'
    with open(poly_file, 'r') as fp:
        geo_dict = json.load(fp)

    # get all of the programs and construction sets
    c_set = constr_set_lib.construction_set_by_identifier('2013::ClimateZone5::SteelFramed')
    office = prog_type_lib.program_type_by_identifier('2013::MediumOffice::ClosedOffice')
    writeup = prog_type_lib.program_type_by_identifier('2013::Laboratory::Office')
    lab_support = prog_type_lib.program_type_by_identifier('2013::Laboratory::Lab with fume hood')
    laboratory = prog_type_lib.program_type_by_identifier('2013::Laboratory::Open lab')
    conference = prog_type_lib.program_type_by_identifier('2013::MediumOffice::Conference')
    classroom = prog_type_lib.program_type_by_identifier('2013::MediumOffice::Classroom')
    corridor = prog_type_lib.program_type_by_identifier('2013::MediumOffice::Corridor')
    storage = prog_type_lib.program_type_by_identifier('2013::MediumOffice::Storage')
    progs = [office, writeup, lab_support, laboratory, conference, classroom,
             corridor, storage]
    prog_keys = ['office', 'writeup', 'lab_support', 'laboratory', 'conference',
                 'classroom', 'corridor', 'storage']

    # create the basic Room objects
    rooms = []
    for prog_key, program in zip(prog_keys, progs):
        for i, room_geo_dict in enumerate(geo_dict[prog_key]):
            room_geo = Face3D.from_dict(room_geo_dict)
            room = Room2D('{}_{}'.format(prog_key, i), room_geo, 3.5)
            room.properties.energy.program_type = program
            room.properties.energy.construction_set = c_set
            room.properties.energy.add_default_ideal_air()
            rooms.append(room)

    # solve adjacency and set windows + shades
    story = Story('Lab_Floor_1', rooms, 4)
    story.remove_room_2d_colinear_vertices(0.01)
    story.intersect_room_2d_adjacency(0.01)
    story.solve_room_2d_adjacency(0.01)
    story.set_outdoor_window_parameters(RepeatingWindowRatio(0.35, 2.8, 0.8, 3))
    story.set_ground_contact(True)
    story.set_top_exposed(True)
    bldg = Building('Lab_Building', [story])

    # create the honeybee model
    model = bldg.to_honeybee(tolerance=0.01)
    model.units = 'Meters'
    model.tolerance = 0.01
    model.angle_tolerance = 1.0

    # generate louvers for all of the apertures
    for ap in model.apertures:
        ap.louvers_by_count(1, 0.5, 0.0, 0.0, Vector2D(1, 0))

    # write the model to a JSON
    dest_file = os.path.join(directory, 'lab_building.hbjson')
    with open(dest_file, 'w') as fp:
        json.dump(model.to_dict(), fp, indent=4)
"""

ghenv.Component.Name = "DF Repeating Window Ratio Parameters"
ghenv.Component.NickName = 'RepeatingRatioPar'
ghenv.Component.Message = '1.2.0'
ghenv.Component.Category = "Dragonfly"
ghenv.Component.SubCategory = '0 :: Create'
ghenv.Component.AdditionalHelpFromDocStrings = "5"

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

try:
    from ladybug_rhino.config import conversion_to_meters
    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 defaults for any blank inputs
    conversion = conversion_to_meters()
    _win_height_ = _win_height_ if _win_height_ is not None else 2.0 / conversion
    _sill_height_ = _sill_height_ if _sill_height_ is not None else 0.8 / conversion
    _horiz_separ_ = _horiz_separ_ if _horiz_separ_ is not None else 3.0 / conversion
    vert_separ_ = vert_separ_ if vert_separ_ is not None else 0.0
    
    win_par = RepeatingWindowRatio(_ratio, _win_height_, _sill_height_,
                                    _horiz_separ_, vert_separ_)