Ejemplo n.º 1
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
Ejemplo n.º 2
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)
Ejemplo n.º 3
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()
Ejemplo n.º 4
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
Ejemplo n.º 5
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)
Ejemplo n.º 6
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
Ejemplo n.º 7
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)
Ejemplo n.º 8
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
Ejemplo n.º 9
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
Ejemplo n.º 10
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
Ejemplo n.º 11
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
Ejemplo n.º 12
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
Ejemplo n.º 13
0
def test_opaque_construction_init():
    """Test the initalization of OpaqueConstruction objects and basic properties."""
    concrete = EnergyMaterial('Concrete', 0.15, 2.31, 2322, 832, 'MediumRough',
                              0.95, 0.75, 0.8)
    insulation = EnergyMaterialNoMass('Insulation R-3', 3, 'MediumSmooth')
    wall_gap = EnergyMaterial('Wall Air Gap', 0.1, 0.67, 1.2925, 1006.1)
    gypsum = EnergyMaterial('Gypsum', 0.0127, 0.16, 784.9, 830, 'MediumRough',
                            0.93, 0.6, 0.65)
    wall_constr = OpaqueConstruction('Generic Wall Construction',
                                     [concrete, insulation, wall_gap, gypsum])
    str(wall_constr)  # test the string representation of the construction
    constr_dup = wall_constr.duplicate()

    assert wall_constr.name == constr_dup.name == 'Generic Wall Construction'
    assert len(wall_constr.materials) == len(constr_dup.materials) == 4
    assert wall_constr.r_value == constr_dup.r_value == \
        pytest.approx(3.29356, rel=1e-2)
    assert wall_constr.u_value == constr_dup.u_value == \
        pytest.approx(0.30362, rel=1e-2)
    assert wall_constr.u_factor == constr_dup.u_factor == \
        pytest.approx(0.2894284, rel=1e-2)
    assert wall_constr.r_factor == constr_dup.r_factor == \
        pytest.approx(3.4550859, rel=1e-2)
    assert wall_constr.mass_area_density == constr_dup.mass_area_density == \
        pytest.approx(358.397, rel=1e-2)
    assert wall_constr.area_heat_capacity == constr_dup.area_heat_capacity == \
        pytest.approx(298189.26, rel=1e-2)
    assert wall_constr.inside_emissivity == constr_dup.inside_emissivity == 0.93
    assert wall_constr.inside_solar_reflectance == \
        constr_dup.inside_solar_reflectance == 0.4
    assert wall_constr.inside_visible_reflectance == \
        constr_dup.inside_visible_reflectance == 0.35
    assert wall_constr.outside_emissivity == \
        constr_dup.outside_emissivity == 0.95
    assert wall_constr.outside_solar_reflectance == \
        constr_dup.outside_solar_reflectance == 0.25
    assert wall_constr.outside_visible_reflectance == \
        constr_dup.outside_visible_reflectance == pytest.approx(0.2, rel=1e-2)
Ejemplo n.º 14
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
Ejemplo n.º 15
0
def test_opaque_lockability():
    """Test the lockability of the construction."""
    concrete = EnergyMaterial('Concrete', 0.15, 2.31, 2322, 832, 'MediumRough',
                              0.95, 0.75, 0.8)
    insulation = EnergyMaterialNoMass('Insulation R-3', 3, 'MediumSmooth')
    wall_gap = EnergyMaterial('Wall Air Gap', 0.1, 0.67, 1.2925, 1006.1)
    gypsum = EnergyMaterial('Gypsum', 0.0127, 0.16, 784.9, 830, 'MediumRough',
                            0.93, 0.6, 0.65)
    wall_constr = OpaqueConstruction('Generic Wall Construction',
                                     [concrete, insulation, wall_gap, gypsum])

    wall_constr.materials = [concrete, wall_gap, gypsum]
    wall_constr.lock()
    with pytest.raises(AttributeError):
        wall_constr.materials = [concrete, insulation, wall_gap, gypsum]
    with pytest.raises(AttributeError):
        wall_constr[0].density = 600
    wall_constr.unlock()
    wall_constr.materials = [concrete, insulation, wall_gap, gypsum]
    wall_constr[0].density = 600
Ejemplo n.º 16
0
def test_set_construction():
    """Test the setting of a construction on a Door."""
    vertices_wall = [[0, 0, 0], [0, 10, 0], [0, 10, 3], [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 = Door.from_vertices('wall door', vertices_wall)
    door.properties.energy.construction = mass_constr

    assert door.properties.energy.construction == mass_constr
    assert door.properties.energy.is_construction_set_by_user

    with pytest.raises(AttributeError):
        door.properties.energy.construction[0].thickness = 0.1
Ejemplo n.º 17
0
def test_set_construction():
    """Test the setting of a construction on a Face."""
    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

    assert face.properties.energy.construction == thick_constr
    assert face.properties.energy.is_construction_set_by_user

    with pytest.raises(AttributeError):
        face.properties.energy.construction[0].thickness = 0.1
Ejemplo n.º 18
0
def test_constructionset_equality():
    """Test the equality of ConstructionSets to one another."""
    default_set = ConstructionSet('Default Set')
    concrete = EnergyMaterial('Concrete', 0.15, 2.31, 2322, 832, 'MediumRough',
                              0.95, 0.75, 0.8)
    wall_constr = OpaqueConstruction('Concrete Construction', [concrete])
    default_set.wall_set.exterior_construction = wall_constr
    new_default_set = default_set.duplicate()

    cnstr_set_list = [default_set, default_set, new_default_set]
    assert cnstr_set_list[0] is cnstr_set_list[1]
    assert cnstr_set_list[0] is not cnstr_set_list[2]
    assert cnstr_set_list[0] == cnstr_set_list[2]

    new_default_set.name = 'ASHRAE 90.1 Construction Set'
    assert cnstr_set_list[0] != cnstr_set_list[2]
Ejemplo n.º 19
0
def test_to_dict():
    """Test the Door to_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])

    drd = door.to_dict()
    assert 'properties' in drd
    assert drd['properties']['type'] == 'DoorProperties'
    assert 'energy' in drd['properties']
    assert drd['properties']['energy']['type'] == 'DoorEnergyProperties'

    door.properties.energy.construction = mass_constr
    drd = door.to_dict()
    assert 'construction' in drd['properties']['energy']
    assert drd['properties']['energy']['construction'] is not None
Ejemplo n.º 20
0
def test_to_dict():
    """Test the Face to_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])

    fd = face.to_dict()
    assert 'properties' in fd
    assert fd['properties']['type'] == 'FaceProperties'
    assert 'energy' in fd['properties']
    assert fd['properties']['energy']['type'] == 'FaceEnergyProperties'

    face.properties.energy.construction = thick_constr
    fd = face.to_dict()
    assert 'construction' in fd['properties']['energy']
    assert fd['properties']['energy']['construction'] is not None
Ejemplo n.º 21
0
    'generic_underground_roof': (_m.insulation, _m.concrete_hw, _m.ceiling_gap,
                                 _m.acoustic_tile),
    'generic_double_pane': (_m.lowe_glass, _m.air_gap, _m.clear_glass),
    'generic_single_pane': (_m.clear_glass),
    'generic_exterior_door': (_m.painted_metal, _m.insulation_thin,
                              _m.painted_metal),
    'generic_interior_door': (_m.wood),
    'air_wall': (_m.air)
}

# establish variables for the default constructions used across the library
# and auto-generate constructions if they were not loaded from default.idf
try:
    generic_exterior_wall = _idf_opaque_constructions['Generic Exterior Wall']
except KeyError:
    generic_exterior_wall = OpaqueConstruction(
        'Generic Exterior Wall', _default_prop['generic_exterior_wall'])
    generic_exterior_wall.lock()
    _idf_opaque_constructions['Generic Exterior Wall'] = generic_exterior_wall

try:
    generic_interior_wall = _idf_opaque_constructions['Generic Interior Wall']
except KeyError:
    generic_interior_wall = OpaqueConstruction(
        'Generic Interior Wall', _default_prop['generic_interior_wall'])
    generic_interior_wall.lock()
    _idf_opaque_constructions['Generic Interior Wall'] = generic_interior_wall

try:
    generic_underground_wall = _idf_opaque_constructions[
        'Generic Underground Wall']
except KeyError:
Ejemplo n.º 22
0
def test_to_from_dict():
    """Test the Model to_dict and from_dict method with a single zone model."""
    room = Room.from_box('Tiny House Zone', 5, 10, 3)
    room.properties.energy.program_type = office_program
    room.properties.energy.hvac = IdealAirSystem()

    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.apertures[0].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].shades[
        0].properties.energy.construction = light_shelf_out
    south_face.apertures[0].shades[
        1].properties.energy.construction = light_shelf_in

    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))
    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))
    aperture.is_operable = True
    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)
    tree_trans = ScheduleRuleset.from_constant_value('Tree Transmittance',
                                                     0.75,
                                                     schedule_types.fractional)
    tree_canopy.properties.energy.transmittance_schedule = tree_trans

    model = Model('Tiny House', [room], orphaned_shades=[tree_canopy])
    model.north_angle = 15
    model_dict = model.to_dict()
    new_model = Model.from_dict(model_dict)
    assert model_dict == new_model.to_dict()

    assert stone in new_model.properties.energy.materials
    assert thermal_mass_constr in new_model.properties.energy.constructions
    assert new_model.rooms[0][
        0].properties.energy.construction == thermal_mass_constr
    assert new_model.rooms[0][3].apertures[0].indoor_shades[
        0].properties.energy.construction == light_shelf_in
    assert new_model.rooms[0][3].apertures[0].outdoor_shades[
        0].properties.energy.construction == light_shelf_out
    assert triple_pane in new_model.properties.energy.constructions
    assert new_model.rooms[0][1].apertures[
        0].properties.energy.construction == triple_pane
    assert new_model.rooms[0][1].apertures[0].is_operable
    assert len(new_model.orphaned_shades) == 1
    assert new_model.north_angle == 15

    assert new_model.rooms[0][0].type == face_types.floor
    assert new_model.rooms[0][1].type == face_types.wall
    assert isinstance(new_model.rooms[0][0].boundary_condition, Ground)
    assert isinstance(new_model.rooms[0][1].boundary_condition, Outdoors)

    assert new_model.rooms[0].properties.energy.program_type == office_program
    assert len(new_model.properties.energy.schedule_type_limits) == 3
    assert len(model.properties.energy.schedules) == 8
    assert new_model.rooms[0].properties.energy.is_conditioned
    assert new_model.rooms[0].properties.energy.hvac == IdealAirSystem()

    assert new_model.orphaned_shades[
        0].properties.energy.transmittance_schedule == tree_trans
Ejemplo n.º 23
0
def test_check_duplicate_construction_set_names():
    """Test the check_duplicate_construction_set_names 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)

    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('Attic Face 1', Face3D(pts_1))
    face_2 = Face('Attic Face 2', Face3D(pts_2))
    face_3 = Face('Attic Face 3', Face3D(pts_3))
    face_4 = Face('Attic Face 4', Face3D(pts_4))
    face_5 = Face('Attic Face 5', 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_adjcency([first_floor, second_floor, attic], 0.01)

    model = Model('Multi Zone Single Family House',
                  [first_floor, second_floor, attic])

    assert model.properties.energy.check_duplicate_construction_set_names(
        False)
    constr_set.unlock()
    constr_set.name = 'Default Generic Construction Set'
    constr_set.lock()
    assert not model.properties.energy.check_duplicate_construction_set_names(
        False)
    with pytest.raises(ValueError):
        model.properties.energy.check_duplicate_construction_set_names(True)
Ejemplo n.º 24
0
def test_to_dict_multizone_house():
    """Test the Model to_dict method with a multi-zone house."""
    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 = office_program
    second_floor.properties.energy.program_type = office_program
    first_floor.properties.energy.hvac = IdealAirSystem()
    second_floor.properties.energy.hvac = IdealAirSystem()
    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('Attic Face 1', Face3D(pts_1))
    face_2 = Face('Attic Face 2', Face3D(pts_2))
    face_3 = Face('Attic Face 3', Face3D(pts_3))
    face_4 = Face('Attic Face 4', Face3D(pts_4))
    face_5 = Face('Attic Face 5', 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_adjcency([first_floor, second_floor, attic], 0.01)

    model = Model('Multi Zone Single Family House',
                  [first_floor, second_floor, attic])
    model_dict = model.to_dict()

    assert 'energy' in model_dict['properties']
    assert 'materials' in model_dict['properties']['energy']
    assert 'constructions' in model_dict['properties']['energy']
    assert 'construction_sets' in model_dict['properties']['energy']
    assert 'global_construction_set' in model_dict['properties']['energy']

    assert len(model_dict['properties']['energy']['materials']) == 16
    assert len(model_dict['properties']['energy']['constructions']) == 16
    assert len(model_dict['properties']['energy']['construction_sets']) == 2

    assert model_dict['rooms'][0]['faces'][5]['boundary_condition'][
        'type'] == 'Surface'
    assert model_dict['rooms'][1]['faces'][0]['boundary_condition'][
        'type'] == 'Surface'
    assert model_dict['rooms'][1]['faces'][5]['boundary_condition'][
        'type'] == 'Surface'
    assert model_dict['rooms'][2]['faces'][0]['boundary_condition'][
        'type'] == 'Surface'

    assert model_dict['rooms'][2]['properties']['energy']['construction_set'] == \
        constr_set.name

    assert model_dict['rooms'][0]['properties']['energy']['program_type'] == \
        model_dict['rooms'][1]['properties']['energy']['program_type'] == \
        office_program.name
    assert model_dict['rooms'][0]['properties']['energy']['hvac'] == \
        model_dict['rooms'][1]['properties']['energy']['hvac'] == \
        IdealAirSystem().to_dict()
    """
Ejemplo n.º 25
0
def test_to_dict_single_zone():
    """Test the Model to_dict method with a single zone model."""
    room = Room.from_box('Tiny House Zone', 5, 10, 3)
    room.properties.energy.program_type = office_program
    room.properties.energy.hvac = IdealAirSystem()

    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])
    model.north_angle = 15

    model_dict = model.to_dict()

    assert 'energy' in model_dict['properties']
    assert 'materials' in model_dict['properties']['energy']
    assert 'constructions' in model_dict['properties']['energy']
    assert 'construction_sets' in model_dict['properties']['energy']
    assert 'global_construction_set' in model_dict['properties']['energy']

    assert len(model_dict['properties']['energy']['materials']) == 16
    assert len(model_dict['properties']['energy']['constructions']) == 18
    assert len(model_dict['properties']['energy']['construction_sets']) == 1

    assert model_dict['rooms'][0]['faces'][0]['properties']['energy']['construction'] == \
        thermal_mass_constr.name
    south_ap_dict = model_dict['rooms'][0]['faces'][3]['apertures'][0]
    assert south_ap_dict['outdoor_shades'][0]['properties']['energy']['construction'] == \
        light_shelf_out.name
    assert south_ap_dict['indoor_shades'][0]['properties']['energy']['construction'] == \
        light_shelf_in.name
    assert model_dict['rooms'][0]['faces'][1]['apertures'][0]['properties']['energy']['construction'] == \
        triple_pane.name

    assert model_dict['rooms'][0]['properties']['energy']['program_type'] == \
        office_program.name
    assert model_dict['rooms'][0]['properties']['energy']['hvac'] == \
        IdealAirSystem().to_dict()
    """