예제 #1
0
def test_check_duplicate_material_names():
    """Test the check_duplicate_material_names method."""
    room = Room.from_box('Tiny House Zone', 5, 10, 3)

    stone = EnergyMaterial('Stone', 0.3, 2.31, 2322, 832, 'Rough', 0.95, 0.75,
                           0.8)
    thin_stone = EnergyMaterial('Thin Stone', 0.05, 2.31, 2322, 832, 'Rough',
                                0.95, 0.75, 0.8)
    thermal_mass_constr = OpaqueConstruction('Custom Construction', [stone])
    door_constr = OpaqueConstruction('Custom Door Construction', [thin_stone])
    room[0].properties.energy.construction = thermal_mass_constr

    north_face = room[1]
    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))
    door.properties.energy.construction = door_constr
    north_face.add_door(door)

    model = Model('Tiny House', [room])

    assert model.properties.energy.check_duplicate_material_names(False)
    thin_stone.unlock()
    thin_stone.name = 'Stone'
    thin_stone.lock()
    assert not model.properties.energy.check_duplicate_material_names(False)
    with pytest.raises(ValueError):
        model.properties.energy.check_duplicate_material_names(True)
예제 #2
0
def test_assign_to_room():
    """Test the assignment of internal masses to rooms."""
    concrete20 = EnergyMaterial('20cm Concrete', 0.2, 2.31, 2322, 832,
                                'MediumRough', 0.95, 0.75, 0.8)
    concrete10 = EnergyMaterial('10cm Concrete', 0.1, 2.31, 2322, 832,
                                'MediumRough', 0.95, 0.75, 0.8)
    thick_constr = OpaqueConstruction('Thick Concrete Construction',
                                      [concrete20])
    thin_constr = OpaqueConstruction('Thin Concrete Construction',
                                     [concrete10])

    room = Room.from_box('ShoeBox', 5, 10, 3, 0)

    table_verts = [
        Point3D(1, 1, 1),
        Point3D(2, 1, 1),
        Point3D(2, 2, 1),
        Point3D(1, 2, 1)
    ]
    table_geo = Face3D(table_verts)
    table_mass = InternalMass.from_geometry('Concrete Table', thick_constr,
                                            [table_geo], 'Meters')
    chair_mass = InternalMass('Concrete Chair', thin_constr, 1)

    assert len(room.properties.energy.internal_masses) == 0
    room.properties.energy.internal_masses = [table_mass]
    assert len(room.properties.energy.internal_masses) == 1
    room.properties.energy.add_internal_mass(chair_mass)

    idf_str = room.to.idf(room)
    assert idf_str.find('InternalMass,') > -1
예제 #3
0
def test_set_construction_set():
    """Test the setting of a ConstructionSet on a Room2D."""
    pts = (Point3D(0, 0, 3), Point3D(10, 0, 3), Point3D(10, 10,
                                                        3), Point3D(0, 10, 3))
    ashrae_base = SimpleWindowRatio(0.4)
    overhang = Overhang(1)
    boundarycs = (bcs.outdoors, bcs.ground, bcs.outdoors, bcs.ground)
    window = (ashrae_base, None, ashrae_base, None)
    shading = (overhang, None, None, None)
    room = Room2D('SquareShoebox', Face3D(pts), 3, boundarycs, window, shading)

    mass_set = ConstructionSet('Thermal Mass Construction Set')
    concrete20 = EnergyMaterial('20cm Concrete', 0.2, 2.31, 2322, 832,
                                'MediumRough', 0.95, 0.75, 0.8)
    concrete10 = EnergyMaterial('10cm Concrete', 0.1, 2.31, 2322, 832,
                                'MediumRough', 0.95, 0.75, 0.8)
    thick_constr = OpaqueConstruction('Thick Concrete Construction',
                                      [concrete20])
    thin_constr = OpaqueConstruction('Thin Concrete Construction',
                                     [concrete10])
    shade_constr = ShadeConstruction('Light Shelf', 0.5, 0.5)
    mass_set.wall_set.exterior_construction = thick_constr
    mass_set.roof_ceiling_set.interior_construction = thin_constr
    mass_set.shade_construction = shade_constr

    room.properties.energy.construction_set = mass_set
    assert room.properties.energy.construction_set == mass_set

    hb_room, adj = room.to_honeybee()
    assert hb_room.properties.energy.construction_set == mass_set
    assert hb_room[1].properties.energy.construction == thick_constr
    assert hb_room[5].properties.energy.construction == thin_constr
    assert hb_room[1].shades[0].properties.energy.construction == shade_constr
예제 #4
0
def test_opaque_temperature_profile():
    """Test the opaque construction temperature profile."""
    concrete = EnergyMaterial('Concrete', 0.15, 2.31, 2322, 832)
    insulation = EnergyMaterial('Insulation', 0.05, 0.049, 265, 836)
    wall_gap = EnergyMaterial('Wall Air Gap', 0.1, 0.67, 1.2925, 1006.1)
    gypsum = EnergyMaterial('Gypsum', 0.0127, 0.16, 784.9, 830)
    wall_constr = OpaqueConstruction('Wall Construction',
                                     [concrete, insulation, wall_gap, gypsum])

    temperatures, r_values = wall_constr.temperature_profile(-18, 21)
    assert len(temperatures) == 7
    assert temperatures[0] == pytest.approx(-18, rel=1e-2)
    assert temperatures[-1] == pytest.approx(21, rel=1e-2)
    assert len(r_values) == 6
    assert sum(r_values) == pytest.approx(wall_constr.r_factor, rel=1e-1)
    assert r_values[-1] == pytest.approx((1 / wall_constr.in_h_simple()),
                                         rel=1)
    for i, mat in enumerate(wall_constr.materials):
        assert mat.r_value == pytest.approx(r_values[i + 1])

    temperatures, r_values = wall_constr.temperature_profile(
        36, 21, 4, 2., 180.0, 100000)
    assert len(temperatures) == 7
    assert temperatures[0] == pytest.approx(36, rel=1e-2)
    assert temperatures[-1] == pytest.approx(21, rel=1e-2)
    assert len(r_values) == 6
예제 #5
0
def create_HB_construction(_name, _layers):
    ''' Builds a HB Style Construction Object from a list of HB-Material layers'''

    try:
        constr = OpaqueConstruction(clean_and_id_ep_string(_name), _layers)
        constr.display_name = _name
        return constr
    except Exception as e:
        print('Error creating Construction', e)
        return None
예제 #6
0
def test_opaque_dict_methods():
    """Test the to/from dict methods."""
    concrete = EnergyMaterial('Concrete', 0.15, 2.31, 2322, 832)
    insulation = EnergyMaterial('Insulation', 0.05, 0.049, 265, 836)
    wall_gap = EnergyMaterial('Wall Air Gap', 0.1, 0.67, 1.2925, 1006.1)
    gypsum = EnergyMaterial('Gypsum', 0.0127, 0.16, 784.9, 830)
    wall_constr = OpaqueConstruction('Wall Construction',
                                     [concrete, insulation, wall_gap, gypsum])
    constr_dict = wall_constr.to_dict()
    new_constr = OpaqueConstruction.from_dict(constr_dict)
    assert constr_dict == new_constr.to_dict()
예제 #7
0
def test_setting_construction():
    """Test the setting of constructions on the ConstructionSet."""
    default_set = ConstructionSet('Thermal Mass Construction Set')
    concrete20 = EnergyMaterial('20cm Concrete', 0.2, 2.31, 2322, 832,
                                'MediumRough', 0.95, 0.75, 0.8)
    concrete10 = EnergyMaterial('10cm Concrete', 0.1, 2.31, 2322, 832,
                                'MediumRough', 0.95, 0.75, 0.8)
    stone_door = EnergyMaterial('Stone Door', 0.05, 2.31, 2322, 832,
                                'MediumRough', 0.95, 0.75, 0.8)
    thick_constr = OpaqueConstruction(
        'Thick Concrete Construction', [concrete20])
    thin_constr = OpaqueConstruction(
        'Thin Concrete Construction', [concrete10])
    door_constr = OpaqueConstruction(
        'Stone Door', [stone_door])
    light_shelf = ShadeConstruction('Light Shelf', 0.5, 0.5, True)

    default_set.wall_set.exterior_construction = thick_constr
    assert default_set.wall_set.exterior_construction == thick_constr
    assert len(default_set.modified_constructions_unique) == 1
    assert len(default_set.modified_materials_unique) == 1

    assert isinstance(default_set.wall_set.exterior_construction[0], EnergyMaterial)
    with pytest.raises(AttributeError):
        default_set.wall_set.exterior_construction[0].thickness = 0.15

    default_set.wall_set.interior_construction = thin_constr
    assert default_set.wall_set.interior_construction == thin_constr
    default_set.wall_set.ground_construction = thick_constr
    assert default_set.wall_set.ground_construction == thick_constr
    default_set.floor_set.exterior_construction = thick_constr
    assert default_set.floor_set.exterior_construction == thick_constr
    default_set.floor_set.interior_construction = thin_constr
    assert default_set.floor_set.interior_construction == thin_constr
    default_set.floor_set.ground_construction = thick_constr
    assert default_set.floor_set.ground_construction == thick_constr
    default_set.roof_ceiling_set.exterior_construction = thick_constr
    assert default_set.roof_ceiling_set.exterior_construction == thick_constr
    default_set.roof_ceiling_set.interior_construction = thin_constr
    assert default_set.roof_ceiling_set.interior_construction == thin_constr
    default_set.roof_ceiling_set.ground_construction = thick_constr
    assert default_set.roof_ceiling_set.ground_construction == thick_constr
    default_set.door_set.exterior_construction = door_constr
    assert default_set.door_set.exterior_construction == door_constr
    default_set.door_set.interior_construction = door_constr
    assert default_set.door_set.interior_construction == door_constr
    default_set.door_set.overhead_construction = door_constr
    assert default_set.door_set.overhead_construction == door_constr
    default_set.shade_construction = light_shelf
    assert default_set.shade_construction == light_shelf

    assert len(default_set.modified_constructions_unique) == 4
    assert len(default_set.modified_materials_unique) == 3
예제 #8
0
def test_check_duplicate_construction_set_identifiers():
    """Test the check_duplicate_construction_set_identifiers method."""
    pts_1 = (Point3D(0, 0, 3), Point3D(0, 10,
                                       3), Point3D(10, 10,
                                                   3), Point3D(10, 0, 3))
    pts_2 = (Point3D(10, 0, 3), Point3D(10, 10,
                                        3), Point3D(20, 10,
                                                    3), Point3D(20, 0, 3))
    room2d_1 = Room2D('Office1', Face3D(pts_1), 3)
    room2d_2 = Room2D('Office2', Face3D(pts_2), 3)
    story = Story('OfficeFloor', [room2d_1, room2d_2])
    story.solve_room_2d_adjacency(0.01)
    story.set_outdoor_window_parameters(SimpleWindowRatio(0.4))
    story.multiplier = 4
    for room in story.room_2ds:
        room.properties.energy.program_type = office_program
        room.properties.energy.add_default_ideal_air()
    building = Building('OfficeBuilding', [story])
    building.separate_top_bottom_floors()

    constr_set = ConstructionSet('Attic Construction Set')
    polyiso = EnergyMaterial('PolyIso', 0.2, 0.03, 43, 1210, 'MediumRough')
    roof_constr = OpaqueConstruction('Attic Roof Construction',
                                     [roof_membrane, polyiso, wood])
    floor_constr = OpaqueConstruction('Attic Floor Construction',
                                      [wood, insulation, wood])
    constr_set.floor_set.interior_construction = floor_constr
    constr_set.roof_ceiling_set.exterior_construction = roof_constr
    building.unique_room_2ds[
        -1].properties.energy.construction_set = constr_set
    building.unique_room_2ds[
        -2].properties.energy.construction_set = constr_set

    tree_canopy_geo1 = Face3D.from_regular_polygon(6, 6,
                                                   Plane(o=Point3D(5, -10, 6)))
    tree_canopy_geo2 = Face3D.from_regular_polygon(
        6, 2, Plane(o=Point3D(-5, -10, 3)))
    tree_canopy = ContextShade('TreeCanopy',
                               [tree_canopy_geo1, tree_canopy_geo2])

    model = Model('NewDevelopment', [building], [tree_canopy])

    assert model.properties.energy.check_duplicate_construction_set_identifiers(
        False)
    constr_set2 = ConstructionSet('Attic Construction Set')
    building.unique_room_2ds[
        -2].properties.energy.construction_set = constr_set2
    assert not model.properties.energy.check_duplicate_construction_set_identifiers(
        False)
    with pytest.raises(ValueError):
        model.properties.energy.check_duplicate_construction_set_identifiers(
            True)
예제 #9
0
def test_check_duplicate_construction_names():
    """Test the check_duplicate_construction_names method."""
    room = Room.from_box('Tiny House Zone', 5, 10, 3)

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

    north_face = room[1]
    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))
    aperture.is_operable = True
    triple_pane = WindowConstruction(
        'Custom Window Construction',
        [clear_glass, air_gap, clear_glass, air_gap, clear_glass])
    aperture.properties.energy.construction = triple_pane
    north_face.add_aperture(aperture)

    model = Model('Tiny House', [room])

    assert model.properties.energy.check_duplicate_construction_names(False)
    triple_pane.unlock()
    triple_pane.name = 'Custom Construction'
    triple_pane.lock()
    assert not model.properties.energy.check_duplicate_construction_names(
        False)
    with pytest.raises(ValueError):
        model.properties.energy.check_duplicate_construction_names(True)
예제 #10
0
def dict_to_construction(constr_dict, raise_exception=True):
    """Get a Python object of any Construction from a dictionary.

    Args:
        constr_dict: A dictionary of any Honeybee energy construction. Note
            that this should be a non-abridged dictionary to be valid.
        raise_exception: Boolean to note whether an excpetion should be raised
            if the object is not identified as a construction. Default: True.

    Returns:
        A Python object derived from the input constr_dict.
    """
    try:  # get the type key from the dictionary
        constr_type = constr_dict['type']
    except KeyError:
        raise ValueError('Construction dictionary lacks required "type" key.')

    if constr_type == 'OpaqueConstruction':
        return OpaqueConstruction.from_dict(constr_dict)
    elif constr_type == 'WindowConstruction':
        return WindowConstruction.from_dict(constr_dict)
    elif constr_type == 'WindowConstructionShade':
        return WindowConstructionShade.from_dict(constr_dict)
    elif constr_type == 'ShadeConstruction':
        return ShadeConstruction.from_dict(constr_dict)
    elif constr_type == 'AirBoundaryConstruction':
        return AirBoundaryConstruction.from_dict(constr_dict)
    elif raise_exception:
        raise ValueError(
            '{} is not a recognized energy Construction type'.format(
                constr_type))
예제 #11
0
def test_duplicate():
    """Test what happens to energy properties when duplicating a Face."""
    verts = [
        Point3D(0, 0, 0),
        Point3D(10, 0, 0),
        Point3D(10, 0, 10),
        Point3D(0, 0, 10)
    ]
    concrete20 = EnergyMaterial('20cm Concrete', 0.2, 2.31, 2322, 832,
                                'MediumRough', 0.95, 0.75, 0.8)
    thick_constr = OpaqueConstruction('Thick Concrete Construction',
                                      [concrete20])

    face_original = Face('wall_face', Face3D(verts))
    face_dup_1 = face_original.duplicate()

    assert face_original.properties.energy.host is face_original
    assert face_dup_1.properties.energy.host is face_dup_1
    assert face_original.properties.energy.host is not face_dup_1.properties.energy.host

    assert face_original.properties.energy.construction == \
        face_dup_1.properties.energy.construction
    face_dup_1.properties.energy.construction = thick_constr
    assert face_original.properties.energy.construction != \
        face_dup_1.properties.energy.construction

    face_dup_2 = face_dup_1.duplicate()

    assert face_dup_1.properties.energy.construction == \
        face_dup_2.properties.energy.construction
    face_dup_2.properties.energy.construction = None
    assert face_dup_1.properties.energy.construction != \
        face_dup_2.properties.energy.construction
예제 #12
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)
예제 #13
0
def test_opaque_to_from_standards_dict():
    """Test the initialization of OpaqueConstruction objects from standards gem."""
    filename = './tests/standards/OpenStudio_Standards_materials.json'
    if filename:
        with open(filename, 'r') as f:
            data_store = json.load(f)
    standards_dict = {
        "name":
        "Metal framed wallsW1_R8.60",
        "intended_surface_type":
        "ExteriorWall",
        "standards_construction_type":
        None,
        "insulation_layer":
        "Typical Insulation",
        "skylight_framing":
        None,
        "materials": [
            "Stucco - 7/8 in. CBES", "W1_R8.60",
            "Air - Metal Wall Framing - 16 or 24 in. OC",
            "Gypsum Board - 1/2 in. CBES"
        ]
    }
    wall_constr = OpaqueConstruction.from_standards_dict(
        standards_dict, data_store)

    assert wall_constr.name == 'Metal framed wallsW1_R8.60'
    assert wall_constr.r_value == pytest.approx(1.7411, rel=1e-2)
    assert wall_constr.u_value == pytest.approx(0.57434, rel=1e-2)
    assert wall_constr.u_factor == pytest.approx(0.524972, rel=1e-2)
    assert wall_constr.r_factor == pytest.approx(1.904860, rel=1e-2)
예제 #14
0
def construction_from_idf(construction_idf, output_file):
    """Translate a Construction IDF file to a honeybee JSON as an array of constructions.

    \b
    Args:
        construction_idf: Full path to a Construction IDF file. Only the constructions
            and materials in this file will be extracted.
    """
    try:
        # re-serialize the Constructions to Python
        opaque_constrs = OpaqueConstruction.extract_all_from_idf_file(construction_idf)
        win_constrs = WindowConstruction.extract_all_from_idf_file(construction_idf)

        # create the honeybee dictionaries
        hb_obj_list = []
        for constr in opaque_constrs[0]:
            hb_obj_list.append(constr.to_dict())
        for constr in win_constrs[0]:
            hb_obj_list.append(constr.to_dict())

        # write out the JSON file
        output_file.write(json.dumps(hb_obj_list))
    except Exception as e:
        _logger.exception('Construction translation failed.\n{}'.format(e))
        sys.exit(1)
    else:
        sys.exit(0)
예제 #15
0
def opaque_construction_by_identifier(construction_identifier):
    """Get an opaque construction from the library given the construction identifier.

    Args:
        construction_identifier: A text string for the identifier of the construction.
    """
    try:
        return _opaque_constructions[construction_identifier]
    except KeyError:
        try:  # search the extension data
            constr_dict = _opaque_constr_standards_dict[
                construction_identifier]
            if constr_dict['type'] == 'OpaqueConstructionAbridged':
                mats = {}
                mat_key = 'layers' if 'layers' in constr_dict else 'materials'
                for mat in constr_dict[mat_key]:
                    mats[mat] = _m.opaque_material_by_identifier(mat)
                return OpaqueConstruction.from_dict_abridged(constr_dict, mats)
            else:  # AirBoundaryConstruction
                try:
                    sch_id = constr_dict['air_mixing_schedule']
                    schs = {sch_id: _s.schedule_by_identifier(sch_id)}
                except KeyError:  # no air mixing key provided
                    schs = {}
                return AirBoundaryConstruction.from_dict_abridged(
                    constr_dict, schs)
        except KeyError:  # construction is nowhere to be found; raise an error
            raise ValueError(
                '"{}" was not found in the opaque energy construction library.'
                .format(construction_identifier))
예제 #16
0
def test_duplicate():
    """Test what happens to energy properties when duplicating a Door."""
    verts = [
        Point3D(0, 0, 0),
        Point3D(1, 0, 0),
        Point3D(1, 0, 3),
        Point3D(0, 0, 3)
    ]
    concrete5 = EnergyMaterial('5cm Concrete', 0.05, 2.31, 2322, 832,
                               'MediumRough', 0.95, 0.75, 0.8)
    mass_constr = OpaqueConstruction('Concrete Door', [concrete5])

    door_original = Door('wall_door', Face3D(verts))
    door_dup_1 = door_original.duplicate()

    assert door_original.properties.energy.host is door_original
    assert door_dup_1.properties.energy.host is door_dup_1
    assert door_original.properties.energy.host is not \
        door_dup_1.properties.energy.host

    assert door_original.properties.energy.construction == \
        door_dup_1.properties.energy.construction
    door_dup_1.properties.energy.construction = mass_constr
    assert door_original.properties.energy.construction != \
        door_dup_1.properties.energy.construction

    door_dup_2 = door_dup_1.duplicate()

    assert door_dup_1.properties.energy.construction == \
        door_dup_2.properties.energy.construction
    door_dup_2.properties.energy.construction = None
    assert door_dup_1.properties.energy.construction != \
        door_dup_2.properties.energy.construction
예제 #17
0
def test_opaque_construction_from_idf():
    """Test the OpaqueConstruction to/from idf methods."""
    concrete = EnergyMaterial('Concrete', 0.15, 2.31, 2322, 832)
    insulation = EnergyMaterial('Insulation', 0.05, 0.049, 265, 836)
    wall_gap = EnergyMaterial('Wall Air Gap', 0.1, 0.67, 1.2925, 1006.1)
    gypsum = EnergyMaterial('Gypsum', 0.0127, 0.16, 784.9, 830)
    wall_constr = OpaqueConstruction('Wall Construction',
                                     [concrete, insulation, wall_gap, gypsum])
    constr_str = wall_constr.to_idf()
    mat_str = [mat.to_idf() for mat in wall_constr.unique_materials]
    new_wall_constr = OpaqueConstruction.from_idf(constr_str, mat_str)
    new_constr_str = new_wall_constr.to_idf()

    assert wall_constr.r_value == new_wall_constr.r_value
    assert wall_constr.r_factor == new_wall_constr.r_factor
    assert wall_constr.thickness == new_wall_constr.thickness
    assert constr_str == new_constr_str
예제 #18
0
def test_from_dict_non_abridged():
    """Test the Model from_dict method with non-abridged objects."""
    first_floor = Room.from_box('FirstFloor', 10, 10, 3, origin=Point3D(0, 0, 0))
    second_floor = Room.from_box('SecondFloor', 10, 10, 3, origin=Point3D(0, 0, 3))
    first_floor.properties.energy.program_type = office_program
    second_floor.properties.energy.program_type = office_program
    first_floor.properties.energy.add_default_ideal_air()
    second_floor.properties.energy.add_default_ideal_air()
    for face in first_floor[1:5]:
        face.apertures_by_ratio(0.2, 0.01)
    for face in second_floor[1:5]:
        face.apertures_by_ratio(0.2, 0.01)

    pts_1 = [Point3D(0, 0, 6), Point3D(0, 10, 6), Point3D(10, 10, 6), Point3D(10, 0, 6)]
    pts_2 = [Point3D(0, 0, 6), Point3D(5, 0, 9), Point3D(5, 10, 9), Point3D(0, 10, 6)]
    pts_3 = [Point3D(10, 0, 6), Point3D(10, 10, 6), Point3D(5, 10, 9), Point3D(5, 0, 9)]
    pts_4 = [Point3D(0, 0, 6), Point3D(10, 0, 6), Point3D(5, 0, 9)]
    pts_5 = [Point3D(10, 10, 6), Point3D(0, 10, 6), Point3D(5, 10, 9)]
    face_1 = Face('AtticFace1', Face3D(pts_1))
    face_2 = Face('AtticFace2', Face3D(pts_2))
    face_3 = Face('AtticFace3', Face3D(pts_3))
    face_4 = Face('AtticFace4', Face3D(pts_4))
    face_5 = Face('AtticFace5', Face3D(pts_5))
    attic = Room('Attic', [face_1, face_2, face_3, face_4, face_5], 0.01, 1)

    constr_set = ConstructionSet('Attic Construction Set')
    polyiso = EnergyMaterial('PolyIso', 0.2, 0.03, 43, 1210, 'MediumRough')
    roof_constr = OpaqueConstruction('Attic Roof Construction',
                                     [roof_membrane, polyiso, wood])
    floor_constr = OpaqueConstruction('Attic Floor Construction',
                                      [wood, insulation, wood])
    constr_set.floor_set.interior_construction = floor_constr
    constr_set.roof_ceiling_set.exterior_construction = roof_constr
    attic.properties.energy.construction_set = constr_set

    Room.solve_adjacency([first_floor, second_floor, attic], 0.01)

    model = Model('MultiZoneSingleFamilyHouse', [first_floor, second_floor, attic])
    model_dict = model.to_dict()

    model_dict['properties']['energy']['program_types'][0] = office_program.to_dict()
    model_dict['properties']['energy']['construction_sets'][0] = constr_set.to_dict()

    rebuilt_model = Model.from_dict(model_dict)
    assert rebuilt_model.rooms[0].properties.energy.program_type == office_program
    assert rebuilt_model.rooms[2].properties.energy.construction_set == constr_set
예제 #19
0
def test_check_duplicate_construction_set_identifiers():
    """Test the check_duplicate_construction_set_identifiers method."""
    first_floor = Room.from_box('First_Floor', 10, 10, 3, origin=Point3D(0, 0, 0))
    second_floor = Room.from_box('Second_Floor', 10, 10, 3, origin=Point3D(0, 0, 3))
    for face in first_floor[1:5]:
        face.apertures_by_ratio(0.2, 0.01)
    for face in second_floor[1:5]:
        face.apertures_by_ratio(0.2, 0.01)
    base_constr_set = ConstructionSet('Lower Floor Construction Set')
    first_floor.properties.energy.construction_set = base_constr_set
    second_floor.properties.energy.construction_set = base_constr_set

    pts_1 = [Point3D(0, 0, 6), Point3D(0, 10, 6), Point3D(10, 10, 6), Point3D(10, 0, 6)]
    pts_2 = [Point3D(0, 0, 6), Point3D(5, 0, 9), Point3D(5, 10, 9), Point3D(0, 10, 6)]
    pts_3 = [Point3D(10, 0, 6), Point3D(10, 10, 6), Point3D(5, 10, 9), Point3D(5, 0, 9)]
    pts_4 = [Point3D(0, 0, 6), Point3D(10, 0, 6), Point3D(5, 0, 9)]
    pts_5 = [Point3D(10, 10, 6), Point3D(0, 10, 6), Point3D(5, 10, 9)]
    face_1 = Face('AtticFace1', Face3D(pts_1))
    face_2 = Face('AtticFace2', Face3D(pts_2))
    face_3 = Face('AtticFace3', Face3D(pts_3))
    face_4 = Face('AtticFace4', Face3D(pts_4))
    face_5 = Face('AtticFace5', Face3D(pts_5))
    attic = Room('Attic', [face_1, face_2, face_3, face_4, face_5], 0.01, 1)

    constr_set = ConstructionSet('Attic Construction Set')
    polyiso = EnergyMaterial('PolyIso', 0.2, 0.03, 43, 1210, 'MediumRough')
    roof_constr = OpaqueConstruction('Attic Roof Construction',
                                     [roof_membrane, polyiso, wood])
    floor_constr = OpaqueConstruction('Attic Floor Construction',
                                      [wood, insulation, wood])
    constr_set.floor_set.interior_construction = floor_constr
    constr_set.roof_ceiling_set.exterior_construction = roof_constr
    attic.properties.energy.construction_set = constr_set

    Room.solve_adjacency([first_floor, second_floor, attic], 0.01)

    model = Model('MultiZoneSingleFamilyHouse', [first_floor, second_floor, attic])

    assert model.properties.energy.check_duplicate_construction_set_identifiers(False)
    constr_set.unlock()
    constr_set.identifier = 'Lower Floor Construction Set'
    constr_set.lock()
    assert not model.properties.energy.check_duplicate_construction_set_identifiers(False)
    with pytest.raises(ValueError):
        model.properties.energy.check_duplicate_construction_set_identifiers(True)
예제 #20
0
def test_set_construction_set():
    """Test the setting of a ConstructionSet on a Story."""
    pts_1 = (Point3D(0, 0, 3), Point3D(0, 10,
                                       3), Point3D(10, 10,
                                                   3), Point3D(10, 0, 3))
    pts_2 = (Point3D(10, 0, 3), Point3D(10, 10,
                                        3), Point3D(20, 10,
                                                    3), Point3D(20, 0, 3))
    pts_3 = (Point3D(0, 10, 3), Point3D(0, 20,
                                        3), Point3D(10, 20,
                                                    3), Point3D(10, 10, 3))
    pts_4 = (Point3D(10, 10, 3), Point3D(10, 20,
                                         3), Point3D(20, 20,
                                                     3), Point3D(20, 10, 3))
    room2d_1 = Room2D('Office1', Face3D(pts_1), 3)
    room2d_2 = Room2D('Office2', Face3D(pts_2), 3)
    room2d_3 = Room2D('Office3', Face3D(pts_3), 3)
    room2d_4 = Room2D('Office4', Face3D(pts_4), 3)
    story = Story('OfficeFloor', [room2d_1, room2d_2, room2d_3, room2d_4])
    story.solve_room_2d_adjacency(0.01)
    story.set_outdoor_window_parameters(SimpleWindowRatio(0.4))

    mass_set = ConstructionSet('Thermal Mass Construction Set')
    concrete20 = EnergyMaterial('20cm Concrete', 0.2, 2.31, 2322, 832,
                                'MediumRough', 0.95, 0.75, 0.8)
    concrete10 = EnergyMaterial('10cm Concrete', 0.1, 2.31, 2322, 832,
                                'MediumRough', 0.95, 0.75, 0.8)
    thick_constr = OpaqueConstruction('Thick Concrete Construction',
                                      [concrete20])
    thin_constr = OpaqueConstruction('Thin Concrete Construction',
                                     [concrete10])
    shade_constr = ShadeConstruction('Light Shelf', 0.5, 0.5)
    mass_set.wall_set.exterior_construction = thick_constr
    mass_set.roof_ceiling_set.interior_construction = thin_constr
    mass_set.shade_construction = shade_constr

    story.properties.energy.construction_set = mass_set
    assert story.properties.energy.construction_set == mass_set
    assert story[0].properties.energy.construction_set == mass_set

    rooms = story.to_honeybee()
    model = hb_model.Model(story.identifier, rooms)
    assert len(model.properties.energy.construction_sets) == 1
    assert model.properties.energy.construction_sets[0] == mass_set
    assert model.rooms[0].properties.energy.construction_set == mass_set
예제 #21
0
def test_set_construction_set():
    """Test the setting of a ConstructionSet on a Room."""
    room = Room.from_box('Shoe Box', 5, 10, 3)
    door_verts = [[1, 0, 0.1], [2, 0, 0.1], [2, 0, 3], [1, 0, 3]]
    room[3].add_door(Door.from_vertices('test_door', door_verts))
    room[1].apertures_by_ratio(0.4, 0.01)
    room[1].apertures[0].overhang(0.5, indoor=False)
    room[1].apertures[0].overhang(0.5, indoor=True)
    room[1].apertures[0].move_shades(Vector3D(0, 0, -0.5))

    mass_set = ConstructionSet('Thermal Mass Construction Set')
    concrete20 = EnergyMaterial('20cm Concrete', 0.2, 2.31, 2322, 832,
                                'MediumRough', 0.95, 0.75, 0.8)
    concrete10 = EnergyMaterial('10cm Concrete', 0.1, 2.31, 2322, 832,
                                'MediumRough', 0.95, 0.75, 0.8)
    stone_door = EnergyMaterial('Stone Door', 0.05, 2.31, 2322, 832,
                                'MediumRough', 0.95, 0.75, 0.8)
    thick_constr = OpaqueConstruction('Thick Concrete Construction',
                                      [concrete20])
    thin_constr = OpaqueConstruction('Thin Concrete Construction',
                                     [concrete10])
    door_constr = OpaqueConstruction('Stone Door', [stone_door])
    shade_constr = ShadeConstruction('Light Shelf', 0.5, 0.5)
    mass_set.wall_set.exterior_construction = thick_constr
    mass_set.roof_ceiling_set.exterior_construction = thin_constr
    mass_set.door_set.exterior_construction = door_constr
    mass_set.shade_construction = shade_constr

    room.properties.energy.construction_set = mass_set
    assert room.properties.energy.construction_set == mass_set
    assert room[1].properties.energy.construction == thick_constr
    assert room[5].properties.energy.construction == thin_constr
    assert room[3].doors[0].properties.energy.construction == door_constr
    assert room[1].apertures[0].shades[
        0].properties.energy.construction == shade_constr

    with pytest.raises(AttributeError):
        room[1].properties.energy.construction.thickness = 0.3
    with pytest.raises(AttributeError):
        room[5].properties.energy.construction.thickness = 0.3
    with pytest.raises(AttributeError):
        room[3].doors[0].properties.energy.construction.thickness = 0.3
예제 #22
0
def test_internal_mass_equality():
    """Test the equality of InternalMass objects."""
    rammed_earth = EnergyMaterial('40cm Rammed Earth', 0.4, 2.31, 2322, 832,
                                  'MediumRough', 0.95, 0.75, 0.8)
    earth_constr = OpaqueConstruction('Rammed Earth Construction',
                                      [rammed_earth])
    stone = EnergyMaterial('Stone Veneer', 0.1, 2.31, 2322, 832, 'MediumRough',
                           0.95, 0.75, 0.8)
    stone_constr = OpaqueConstruction('Stone Veneer', [stone])

    chimney_mass = InternalMass('Rammed Earth Chimney', earth_constr, 10)
    chimney_mass_dup = chimney_mass.duplicate()
    chimney_mass_alt = InternalMass('Rammed Earth Chimney', stone_constr, 10)

    assert chimney_mass is chimney_mass
    assert chimney_mass is not chimney_mass_dup
    assert chimney_mass == chimney_mass_dup
    chimney_mass_dup.area = 5
    assert chimney_mass != chimney_mass_dup
    assert chimney_mass != chimney_mass_alt
예제 #23
0
def model_complete_multi_zone_office(directory):
    first_floor = Room.from_box('First_Floor', 10, 10, 3, origin=Point3D(0, 0, 0))
    second_floor = Room.from_box('Second_Floor', 10, 10, 3, origin=Point3D(0, 0, 3))
    first_floor.properties.energy.program_type = prog_type_lib.office_program
    second_floor.properties.energy.program_type = prog_type_lib.office_program
    first_floor.properties.energy.add_default_ideal_air()
    second_floor.properties.energy.add_default_ideal_air()
    for face in first_floor[1:5]:
        face.apertures_by_ratio(0.2, 0.01)
    for face in second_floor[1:5]:
        face.apertures_by_ratio(0.2, 0.01)

    pts_1 = [Point3D(0, 0, 6), Point3D(0, 10, 6), Point3D(10, 10, 6), Point3D(10, 0, 6)]
    pts_2 = [Point3D(0, 0, 6), Point3D(5, 0, 9), Point3D(5, 10, 9), Point3D(0, 10, 6)]
    pts_3 = [Point3D(10, 0, 6), Point3D(10, 10, 6), Point3D(5, 10, 9), Point3D(5, 0, 9)]
    pts_4 = [Point3D(0, 0, 6), Point3D(10, 0, 6), Point3D(5, 0, 9)]
    pts_5 = [Point3D(10, 10, 6), Point3D(0, 10, 6), Point3D(5, 10, 9)]
    face_1 = Face('AtticFace1', Face3D(pts_1))
    face_2 = Face('AtticFace2', Face3D(pts_2))
    face_3 = Face('AtticFace3', Face3D(pts_3))
    face_4 = Face('AtticFace4', Face3D(pts_4))
    face_5 = Face('AtticFace5', Face3D(pts_5))
    attic = Room('Attic', [face_1, face_2, face_3, face_4, face_5], 0.01, 1)

    constr_set = ConstructionSet('Attic Construction Set')
    polyiso = EnergyMaterial('PolyIso', 0.2, 0.03, 43, 1210, 'MediumRough')
    roof_constr = OpaqueConstruction('Attic Roof Construction',
                                     [roof_membrane, polyiso, wood])
    floor_constr = OpaqueConstruction('Attic Floor Construction',
                                      [wood, insulation, wood])
    constr_set.floor_set.interior_construction = floor_constr
    constr_set.roof_ceiling_set.exterior_construction = roof_constr
    attic.properties.energy.construction_set = constr_set

    Room.solve_adjacency([first_floor, second_floor, attic], 0.01)

    model = Model('Multi_Zone_Single_Family_House', [first_floor, second_floor, attic])

    dest_file = os.path.join(directory, 'model_complete_multi_zone_office.json')
    with open(dest_file, 'w') as fp:
        json.dump(model.to_dict(), fp, indent=4)
예제 #24
0
def test_internal_mass_dict_methods():
    """Test the to/from dict methods."""
    rammed_earth = EnergyMaterial('40cm Rammed Earth', 0.4, 2.31, 2322, 832,
                                  'MediumRough', 0.95, 0.75, 0.8)
    earth_constr = OpaqueConstruction('Rammed Earth Construction',
                                      [rammed_earth])
    chimney_mass = InternalMass('Rammed Earth Chimney', earth_constr, 10)

    mass_dict = chimney_mass.to_dict()
    new_chimney_mass = InternalMass.from_dict(mass_dict)
    assert new_chimney_mass == chimney_mass
    assert mass_dict == new_chimney_mass.to_dict()
예제 #25
0
def test_opaque_symmetric():
    """Test that the opaque construction is_symmetric property."""
    concrete = EnergyMaterial('Concrete', 0.15, 2.31, 2322, 832)
    insulation = EnergyMaterial('Insulation', 0.05, 0.049, 265, 836)
    wall_gap = EnergyMaterial('Wall Air Gap', 0.1, 0.67, 1.2925, 1006.1)
    gypsum = EnergyMaterial('Gypsum', 0.0127, 0.16, 784.9, 830)
    wall_constr_1 = OpaqueConstruction(
        'Wall Construction', [concrete, insulation, wall_gap, gypsum])
    wall_constr_2 = OpaqueConstruction(
        'Wall Construction', [gypsum, wall_gap, gypsum])
    wall_constr_3 = OpaqueConstruction(
        'Wall Construction', [concrete])
    wall_constr_4 = OpaqueConstruction(
        'Wall Construction', [concrete, concrete])
    wall_constr_5 = OpaqueConstruction(
        'Other Wall Construction', [concrete, insulation, wall_gap, insulation, concrete])

    assert not wall_constr_1.is_symmetric
    assert wall_constr_2.is_symmetric
    assert wall_constr_3.is_symmetric
    assert wall_constr_4.is_symmetric
    assert wall_constr_5.is_symmetric
예제 #26
0
def test_internal_mass_idf_methods():
    """Test the to/from IDF methods."""
    rammed_earth = EnergyMaterial('40cm Rammed Earth', 0.4, 2.31, 2322, 832,
                                  'MediumRough', 0.95, 0.75, 0.8)
    earth_constr = OpaqueConstruction('Rammed Earth Construction',
                                      [rammed_earth])
    chimney_mass = InternalMass('Rammed Earth Chimney', earth_constr, 10)

    mass_idf = chimney_mass.to_idf('Test Room')
    new_chimney_mass = InternalMass.from_idf(
        mass_idf, {'Rammed Earth Construction': earth_constr})
    assert new_chimney_mass == chimney_mass
    assert mass_idf == new_chimney_mass.to_idf('Test Room')
예제 #27
0
def test_internal_mass_init():
    """Test the initialization of InternalMass and basic properties."""
    rammed_earth = EnergyMaterial('40cm Rammed Earth', 0.4, 2.31, 2322, 832,
                                  'MediumRough', 0.95, 0.75, 0.8)
    earth_constr = OpaqueConstruction('Rammed Earth Construction',
                                      [rammed_earth])
    chimney_mass = InternalMass('Rammed Earth Chimney', earth_constr, 10)
    str(chimney_mass)  # test the string representation

    assert chimney_mass.identifier == chimney_mass.display_name == 'Rammed Earth Chimney'
    assert chimney_mass.construction == earth_constr
    assert chimney_mass.area == 10

    stone = EnergyMaterial('Stone Veneer', 0.1, 2.31, 2322, 832, 'MediumRough',
                           0.95, 0.75, 0.8)
    stone_constr = OpaqueConstruction('Stone Veneer', [stone])

    chimney_mass.construction = stone_constr
    chimney_mass.area = 8

    assert chimney_mass.construction == stone_constr
    assert chimney_mass.area == 8
예제 #28
0
def test_from_dict():
    """Test the Face from_dict method with energy properties."""
    face = Face.from_vertices(
        'wall_face', [[0, 0, 0], [10, 0, 0], [10, 0, 10], [0, 0, 10]])
    concrete20 = EnergyMaterial('20cm Concrete', 0.2, 2.31, 2322, 832,
                                'MediumRough', 0.95, 0.75, 0.8)
    thick_constr = OpaqueConstruction('Thick Concrete Construction', [concrete20])
    face.properties.energy.construction = thick_constr

    fd = face.to_dict()
    new_face = Face.from_dict(fd)
    assert new_face.properties.energy.construction == thick_constr
    assert new_face.to_dict() == fd
예제 #29
0
def test_opaque_equivalency():
    """Test the equality of an opaque construction to another."""
    concrete = EnergyMaterial('Concrete', 0.15, 2.31, 2322, 832)
    insulation = EnergyMaterial('Insulation', 0.05, 0.049, 265, 836)
    wall_gap = EnergyMaterial('Wall Air Gap', 0.1, 0.67, 1.2925, 1006.1)
    gypsum = EnergyMaterial('Gypsum', 0.0127, 0.16, 784.9, 830)
    wall_constr_1 = OpaqueConstruction(
        'Wall Construction', [concrete, insulation, wall_gap, gypsum])
    wall_constr_2 = wall_constr_1.duplicate()
    wall_constr_3 = OpaqueConstruction(
        'Wall Construction', [concrete, wall_gap, gypsum, insulation])
    wall_constr_4 = OpaqueConstruction(
        'Other Wall Construction', [concrete, insulation, wall_gap, gypsum])

    collection = [wall_constr_1, wall_constr_1, wall_constr_2, wall_constr_3]
    assert len(set(collection)) == 2
    assert wall_constr_1 == wall_constr_2
    assert wall_constr_1 != wall_constr_3
    assert wall_constr_1 != wall_constr_4

    wall_constr_2.name = 'Roof Construction'
    assert wall_constr_1 != wall_constr_2
예제 #30
0
def test_from_dict():
    """Test the Door from_dict method with energy properties."""
    door = Door.from_vertices('front_door',
                              [[0, 0, 0], [10, 0, 0], [10, 0, 10], [0, 0, 10]])
    concrete5 = EnergyMaterial('5cm Concrete', 0.05, 2.31, 2322, 832,
                               'MediumRough', 0.95, 0.75, 0.8)
    mass_constr = OpaqueConstruction('Concrete Door', [concrete5])
    door.properties.energy.construction = mass_constr

    drd = door.to_dict()
    new_door = Door.from_dict(drd)
    assert new_door.properties.energy.construction == mass_constr
    assert new_door.to_dict() == drd