Esempio n. 1
0
def single_family_home(directory):
    poly_file = './scripts/geometry/single_family_geo.json'
    with open(poly_file, 'r') as fp:
        geo_dict = json.load(fp)

    # create the basic Room objects
    program = prog_type_lib.program_type_by_identifier('2013::MidriseApartment::Apartment')
    c_set = constr_set_lib.construction_set_by_identifier('2013::ClimateZone5::SteelFramed')
    rooms = []
    for i, room_geo_dict in enumerate(geo_dict['rooms']):
        room_geo = Polyface3D.from_dict(room_geo_dict)
        room_geo.merge_overlapping_edges(0.01, math.radians(1))
        room = Room.from_polyface3d('House_Room_{}'.format(i), room_geo)
        room.properties.energy.program_type = program
        room.properties.energy.construction_set = c_set
        room.properties.energy.add_default_ideal_air()
        rooms.append(room)

    # make some of the rooms different to make it interesting
    program2 = prog_type_lib.program_type_by_identifier('2013::MidriseApartment::Corridor')
    rooms[6].properties.energy.program_type = program2
    cook_vals = [0, 0, 0, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0, 0, 0, 0, 1.0, 0, 0, 0, 0, 0, 0, 0]
    cook_meals = ScheduleRuleset.from_daily_values('Cooking_Meals', cook_vals)
    kitchen_equip = GasEquipment('Kitchen Stove', 20, cook_meals)
    rooms[0].properties.energy.gas_equipment = kitchen_equip

    # add the apertures to the rooms
    apertures = []
    for i, ap_geo in enumerate(geo_dict['apertures']):
        ap_face = Face3D.from_dict(ap_geo)
        hb_ap = Aperture('House_Aperture_{}'.format(i), ap_face)
        hb_ap.extruded_border(0.3)
        apertures.append(hb_ap)

    # assign apertures and solve adjacency
    for room in rooms:
        for face in room.faces:
            for sf in apertures:
                if face.geometry.is_sub_face(sf.geometry, 0.5, 1.0):
                    face.add_aperture(sf)
    Room.solve_adjacency(rooms, 0.01)

    # load up the context shades
    shades = []
    for i, shd_geo in enumerate(geo_dict['shades']):
        shd_face = Face3D.from_dict(shd_geo)
        shades.append(Shade('Context_Shade_{}'.format(i), shd_face))

    # put it all together in a Model and write out the JSON
    model = Model('Single_Family_Home', rooms=rooms, orphaned_shades=shades,
                  units='Meters', tolerance=0.01, angle_tolerance=1.0)
    dest_file = os.path.join(directory, 'single_family_home.hbjson')
    with open(dest_file, 'w') as fp:
        json.dump(model.to_dict(), fp, indent=4)
Esempio n. 2
0
def test_aperture_add_prefix():
    """Test the aperture add_prefix method."""
    pts_1 = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(5, 0,
                                                         3), Point3D(5, 0, 0))
    aperture = Aperture('RectangleWindow', Face3D(pts_1))
    aperture.extruded_border(0.1)
    prefix = 'New'
    aperture.add_prefix(prefix)

    assert aperture.identifier.startswith(prefix)
    for shd in aperture.shades:
        assert shd.identifier.startswith(prefix)
Esempio n. 3
0
def test_aperture_extruded_border():
    """Test the creation of an extruded border for Aperture objects."""
    pts_1 = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(5, 0, 3), Point3D(5, 0, 0))
    pts_2 = (Point3D(0, 0, 0), Point3D(2, 0, 3), Point3D(4, 0, 3))
    aperture_1 = Aperture('Rectangle Window', Face3D(pts_1))
    aperture_2 = Aperture('Triangle Window', Face3D(pts_2))

    aperture_1.extruded_border(0.1)
    aperture_2.extruded_border(0.1)
    aperture_1.extruded_border(0.1, True)
    aperture_2.extruded_border(0.1, True)

    assert len(aperture_1.shades) == 8
    assert aperture_1.outdoor_shades[0].center.y > 0
    assert len(aperture_2.shades) == 6
    assert aperture_2.outdoor_shades[0].center.y > 0
    assert aperture_1.indoor_shades[0].center.y < 0
    assert aperture_2.indoor_shades[0].center.y < 0