示例#1
0
def create_EP_const(_win_EP_material):
    """ Creates an 'E+' style construction for the window

    Args:
        _win_EP_material (): The E+ Material for the window
    Returns:
        constr (): The new E+ Construction for the window
    """

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

    try:  # import the honeybee-energy dependencies
        from honeybee_energy.construction.window import WindowConstruction
        from honeybee_energy.lib.materials import window_material_by_identifier
    except ImportError as e:
        raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e))
    
    material_objs = []
    for material in [_win_EP_material]:
        if isinstance(material, str):
            material = window_material_by_identifier(material)
        material_objs.append(material)
    
    name = 'PHPP_CONST_{}'.format(_win_EP_material.display_name)

    constr = WindowConstruction(clean_and_id_ep_string(name), material_objs)
    constr.display_name = name

    return constr
def construction_window_triple(directory):
    triple_pane = WindowConstruction(
        'Triple Pane Argon',
        [lowe_glass, argon_gap, lowe_glass, argon_gap, clear_glass])
    dest_file = os.path.join(directory, 'construction_window_triple.json')
    with open(dest_file, 'w') as fp:
        json.dump(triple_pane.to_dict(abridged=True), fp, indent=4)
def construction_window_blinds(directory):
    blinds = EnergyWindowMaterialBlind('Generic Aluminium Blinds')
    window_with_blinds = WindowConstruction(
        'Triple Pane Argon', [lowe_glass, argon_gap, lowe_glass, blinds])
    dest_file = os.path.join(directory, 'construction_window_blinds.json')
    with open(dest_file, 'w') as fp:
        json.dump(window_with_blinds.to_dict(abridged=True), fp, indent=4)
示例#4
0
def test_window_construction_init_shade():
    """Test the initalization of WindowConstruction objects with shades."""
    lowe_glass = EnergyWindowMaterialGlazing('Low-e Glass', 0.00318, 0.4517,
                                             0.359, 0.714, 0.207, 0, 0.84,
                                             0.046578, 1.0)
    clear_glass = EnergyWindowMaterialGlazing('Clear Glass', 0.005715,
                                              0.770675, 0.07, 0.8836, 0.0804,
                                              0, 0.84, 0.84, 1.0)
    gap = EnergyWindowMaterialGas('air gap', thickness=0.0127)
    shade_mat = EnergyWindowMaterialShade('Low-e Diffusing Shade', 0.025, 0.15,
                                          0.5, 0.25, 0.5, 0, 0.4, 0.2, 0.1,
                                          0.75, 0.25)
    double_low_e_shade = WindowConstruction(
        'Double Low-E with Shade', [lowe_glass, gap, clear_glass, shade_mat])
    double_low_e_between_shade = WindowConstruction(
        'Double Low-E Between Shade', [lowe_glass, shade_mat, clear_glass])
    double_low_e_ext_shade = WindowConstruction(
        'Double Low-E Outside Shade',
        [shade_mat, lowe_glass, gap, clear_glass])

    assert double_low_e_shade.name == 'Double Low-E with Shade'
    assert double_low_e_shade.u_factor == pytest.approx(0.9091, rel=1e-2)
    assert double_low_e_between_shade.name == 'Double Low-E Between Shade'
    assert double_low_e_between_shade.u_factor == pytest.approx(1.13374,
                                                                rel=1e-2)
    assert double_low_e_ext_shade.name == 'Double Low-E Outside Shade'
    assert double_low_e_ext_shade.u_factor == pytest.approx(0.97678, rel=1e-2)
示例#5
0
def test_window_construction_init_blind():
    """Test the initalization of WindowConstruction objects with blinds."""
    lowe_glass = EnergyWindowMaterialGlazing('Low-e Glass', 0.00318, 0.4517,
                                             0.359, 0.714, 0.207, 0, 0.84,
                                             0.046578, 1.0)
    clear_glass = EnergyWindowMaterialGlazing('Clear Glass', 0.005715,
                                              0.770675, 0.07, 0.8836, 0.0804,
                                              0, 0.84, 0.84, 1.0)
    gap = EnergyWindowMaterialGas('air gap', thickness=0.0127)
    shade_mat = EnergyWindowMaterialBlind('Plastic Blind', 'Vertical', 0.025,
                                          0.01875, 0.003, 90, 0.2, 0.05, 0.4,
                                          0.05, 0.45, 0, 0.95, 0.1, 1)
    double_low_e_shade = WindowConstruction(
        'Double Low-E with Shade', [lowe_glass, gap, clear_glass, shade_mat])
    double_low_e_between_shade = WindowConstruction(
        'Double Low-E Between Shade', [lowe_glass, shade_mat, clear_glass])
    double_low_e_ext_shade = WindowConstruction(
        'Double Low-E Outside Shade',
        [shade_mat, lowe_glass, gap, clear_glass])

    assert double_low_e_shade.name == 'Double Low-E with Shade'
    assert double_low_e_shade.u_factor == pytest.approx(1.26296, rel=1e-2)
    assert double_low_e_between_shade.name == 'Double Low-E Between Shade'
    assert double_low_e_between_shade.u_factor == pytest.approx(1.416379,
                                                                rel=1e-2)
    assert double_low_e_ext_shade.name == 'Double Low-E Outside Shade'
    assert double_low_e_ext_shade.u_factor == pytest.approx(1.2089, rel=1e-2)
示例#6
0
def test_window_temperature_profile():
    """Test the window construction temperature profile."""
    clear_glass = EnergyWindowMaterialGlazing('Clear Glass', 0.005715,
                                              0.770675, 0.07, 0.8836, 0.0804,
                                              0, 0.84, 0.84, 1.0)
    gap = EnergyWindowMaterialGas('air gap', thickness=0.0127)
    triple_clear = WindowConstruction(
        'Triple Clear Window',
        [clear_glass, gap, clear_glass, gap, clear_glass])
    temperatures, r_values = triple_clear.temperature_profile()

    assert len(temperatures) == 8
    assert temperatures[0] == pytest.approx(-18, rel=1e-2)
    assert temperatures[-1] == pytest.approx(21, rel=1e-2)
    assert len(r_values) == 7
    assert sum(r_values) == pytest.approx(triple_clear.r_factor, rel=1e-1)
    assert r_values[-1] == pytest.approx((1 / triple_clear.in_h_simple()),
                                         rel=1)

    temperatures, r_values = triple_clear.temperature_profile(
        36, 21, 4, 2., 180.0, 100000)
    assert len(temperatures) == 8
    assert temperatures[0] == pytest.approx(36, rel=1e-2)
    assert temperatures[-1] == pytest.approx(21, rel=1e-2)
    assert len(r_values) == 7
示例#7
0
def test_setting_window_construction():
    """Test the setting of aperture and glass door constructions on ConstructionSet."""
    default_set = ConstructionSet('Tinted Window Set')
    tinted_glass = EnergyWindowMaterialGlazing(
        'Tinted Glass', 0.006, 0.35, 0.03, 0.884, 0.0804, 0, 0.84, 0.84, 1.0)
    gap = EnergyWindowMaterialGas('Window Air Gap', thickness=0.0127)
    double_tint = WindowConstruction(
        'Double Tinted Window', [tinted_glass, gap, tinted_glass])
    single_tint = WindowConstruction(
        'Single Tinted Window', [tinted_glass])

    default_set.aperture_set.window_construction = double_tint
    assert default_set.aperture_set.window_construction == double_tint
    assert len(default_set.modified_constructions_unique) == 1
    assert len(default_set.modified_materials_unique) == 2

    assert isinstance(default_set.aperture_set.window_construction[0],
                      EnergyWindowMaterialGlazing)
    with pytest.raises(AttributeError):
        default_set.aperture_set.window_construction[0].thickness = 0.003

    default_set.aperture_set.interior_construction = single_tint
    assert default_set.aperture_set.interior_construction == single_tint
    default_set.aperture_set.skylight_construction = double_tint
    assert default_set.aperture_set.skylight_construction == double_tint
    default_set.aperture_set.operable_construction = double_tint
    assert default_set.aperture_set.operable_construction == double_tint

    default_set.door_set.exterior_glass_construction = double_tint
    assert default_set.door_set.exterior_glass_construction == double_tint
    default_set.door_set.interior_glass_construction = single_tint
    assert default_set.door_set.interior_glass_construction == single_tint

    assert len(default_set.modified_constructions_unique) == 2
    assert len(default_set.modified_materials_unique) == 2
示例#8
0
def test_window_dict_methods():
    """Test the to/from dict methods."""
    clear_glass = EnergyWindowMaterialGlazing(
        'Clear Glass', 0.005715, 0.770675, 0.07, 0.8836, 0.0804,
        0, 0.84, 0.84, 1.0)
    gap = EnergyWindowMaterialGas('air gap', thickness=0.0127)
    triple_clear = WindowConstruction(
        'Triple Clear Window', [clear_glass, gap, clear_glass, gap, clear_glass])
    constr_dict = triple_clear.to_dict()
    new_constr = WindowConstruction.from_dict(constr_dict)
    assert constr_dict == new_constr.to_dict()
示例#9
0
def window_construction_by_identifier(construction_identifier):
    """Get an window construction from the library given the construction identifier.

    Args:
        construction_identifier: A text string for the identifier of the construction.
    """
    try:
        return _window_constructions[construction_identifier]
    except KeyError:
        try:  # search the extension data
            constr_dict = _window_constr_standards_dict[
                construction_identifier]
            if constr_dict['type'] == 'WindowConstructionAbridged':
                mats = {}
                for mat in constr_dict['layers']:
                    mats[mat] = _m.window_material_by_identifier(mat)
                return WindowConstruction.from_dict_abridged(constr_dict, mats)
            else:  # WindowConstructionShade
                mats = {}
                for mat in constr_dict['window_construction']['layers']:
                    mats[mat] = _m.window_material_by_identifier(mat)
                shd_mat = constr_dict['shade_material']
                mats[shd_mat] = _m.window_material_by_identifier(shd_mat)
                try:
                    sch_id = constr_dict['schedule']
                    schs = {sch_id: _s.schedule_by_identifier(sch_id)}
                except KeyError:  # no schedule key provided
                    schs = {}
                return WindowConstructionShade.from_dict_abridged(
                    constr_dict, mats, schs)
        except KeyError:  # construction is nowhere to be found; raise an error
            raise ValueError(
                '"{}" was not found in the window energy construction library.'
                .format(construction_identifier))
示例#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_window_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":
        "U 0.19 SHGC 0.20 Trp LoE Film (55) Bronze 6mm/13mm Air",
        "intended_surface_type":
        "ExteriorWindow",
        "standards_construction_type":
        "Metal framing (all other)",
        "insulation_layer":
        None,
        "skylight_framing":
        None,
        "materials":
        ["BRONZE 6MM", "AIR 13MM", "COATED POLY-55", "AIR 13MM", "CLEAR 3MM"]
    }
    glaz_constr = WindowConstruction.from_standards_dict(
        standards_dict, data_store)

    assert glaz_constr.name == 'U 0.19 SHGC 0.20 Trp LoE Film (55) Bronze 6mm/13mm Air'
    assert glaz_constr.r_value == pytest.approx(0.645449, rel=1e-2)
    assert glaz_constr.u_value == pytest.approx(1.549307, rel=1e-2)
    assert glaz_constr.u_factor == pytest.approx(1.2237779, rel=1e-2)
    assert glaz_constr.r_factor == pytest.approx(0.817141, rel=1e-2)
示例#12
0
def test_window_shade_lockability():
    """Test the lockability of the WindowConstructionShade construction."""
    clear_glass = EnergyWindowMaterialGlazing(
        'Clear Glass', 0.005715, 0.770675, 0.07, 0.8836, 0.0804,
        0, 0.84, 0.84, 1.0)
    gap = EnergyWindowMaterialGas('air gap', thickness=0.0127)
    double_clear = WindowConstruction(
        'Double Clear Window', [clear_glass, gap, clear_glass])
    shade_mat = EnergyWindowMaterialShade(
        'Low-e Diffusing Shade', 0.005, 0.15, 0.5, 0.25, 0.5, 0, 0.4,
        0.2, 0.1, 0.75, 0.25)
    sched = ScheduleRuleset.from_daily_values(
        'NighSched', [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                      0, 0, 0, 0, 0, 1, 1, 1])
    double_low_e_ec = WindowConstructionShade(
        'Double Low-E Inside EC', double_clear, shade_mat, 'Exterior',
        'OnIfHighSolarOnWindow', 200, sched)

    with pytest.raises(AttributeError):
        double_low_e_ec.window_construction.materials = \
            [clear_glass, gap, clear_glass, gap, clear_glass]
    with pytest.raises(AttributeError):
        double_low_e_ec.window_construction.schedule.identifier = 'ScheduleName'
    with pytest.raises(AttributeError):
        double_low_e_ec.shade_location = 'Interior'

    double_low_e_ec.control_type = 'AlwaysOn'
    double_low_e_ec.lock()
    with pytest.raises(AttributeError):
        double_low_e_ec.control_type = 'OnIfHighSolarOnWindow'
    double_low_e_ec.unlock()
    double_low_e_ec.control_type = 'OnIfHighSolarOnWindow'
示例#13
0
def test_constructionset_dict_methods():
    """Test the to/from dict methods."""
    insulated_set = ConstructionSet('Insulated Set')
    clear_glass = EnergyWindowMaterialGlazing(
        'Clear Glass', 0.005715, 0.770675, 0.07, 0.8836, 0.0804,
        0, 0.84, 0.84, 1.0)
    gap = EnergyWindowMaterialGas('air gap', thickness=0.0127)
    triple_clear = WindowConstruction(
        'Triple Clear Window', [clear_glass, gap, clear_glass, gap, clear_glass])

    insulated_set.aperture_set.window_construction = triple_clear
    constr_dict = insulated_set.to_dict()

    assert constr_dict['wall_set']['exterior_construction'] is None
    assert constr_dict['wall_set']['interior_construction'] is None
    assert constr_dict['wall_set']['ground_construction'] is None
    assert constr_dict['floor_set']['exterior_construction'] is None
    assert constr_dict['floor_set']['interior_construction'] is None
    assert constr_dict['floor_set']['ground_construction'] is None
    assert constr_dict['roof_ceiling_set']['exterior_construction'] is None
    assert constr_dict['roof_ceiling_set']['interior_construction'] is None
    assert constr_dict['roof_ceiling_set']['ground_construction'] is None
    assert constr_dict['aperture_set']['window_construction'] is not None
    assert constr_dict['aperture_set']['interior_construction'] is None
    assert constr_dict['aperture_set']['skylight_construction'] is None
    assert constr_dict['aperture_set']['operable_construction'] is None
    assert constr_dict['door_set']['exterior_construction'] is None
    assert constr_dict['door_set']['interior_construction'] is None
    assert constr_dict['door_set']['exterior_glass_construction'] is None
    assert constr_dict['door_set']['interior_glass_construction'] is None
    assert constr_dict['door_set']['overhead_construction'] is None
    assert constr_dict['shade_construction'] is None

    new_constr = ConstructionSet.from_dict(constr_dict)
    assert constr_dict == new_constr.to_dict()
示例#14
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)
示例#15
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)
示例#16
0
def test_window_shade_equivalency():
    """Test the equality of a WindowConstructionShade construction to another."""
    clear_glass = EnergyWindowMaterialGlazing(
        'Clear Glass', 0.005715, 0.770675, 0.07, 0.8836, 0.0804,
        0, 0.84, 0.84, 1.0)
    gap = EnergyWindowMaterialGas('air gap', thickness=0.0127)
    double_clear = WindowConstruction(
        'Double Clear Window', [clear_glass, gap, clear_glass])
    shade_mat = EnergyWindowMaterialShade(
        'Low-e Diffusing Shade', 0.005, 0.15, 0.5, 0.25, 0.5, 0, 0.4,
        0.2, 0.1, 0.75, 0.25)
    sched = ScheduleRuleset.from_daily_values(
        'NighSched', [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                      0, 0, 0, 0, 0, 1, 1, 1])
    double_low_e_ec = WindowConstructionShade(
        'Double Low-E Inside EC', double_clear, shade_mat, 'Exterior',
        'OnIfHighSolarOnWindow', 200, sched)
    double_low_e_ec_2 = double_low_e_ec.duplicate()
    double_low_e_ec_3 = WindowConstructionShade(
        'Double Low-E Inside EC', double_clear, shade_mat, 'Exterior',
        'AlwaysOn', None, sched)

    collection = [double_low_e_ec, double_low_e_ec, double_low_e_ec_2, double_low_e_ec_3]
    assert len(set(collection)) == 2
    assert double_low_e_ec == double_low_e_ec_2
    assert double_low_e_ec != double_low_e_ec_3
    assert double_low_e_ec_2 != double_low_e_ec_3

    double_low_e_ec_2.identifier = 'Cool Window'
    assert double_low_e_ec != double_low_e_ec_2
示例#17
0
def test_window_construction_ec_init():
    """Test the initialization of WindowConstructionShade objects with electrochromic."""
    lowe_glass = EnergyWindowMaterialGlazing(
        'Low-e Glass', 0.00318, 0.4517, 0.359, 0.714, 0.207,
        0, 0.84, 0.046578, 1.0)
    clear_glass = EnergyWindowMaterialGlazing(
        'Clear Glass', 0.005715, 0.770675, 0.07, 0.8836, 0.0804,
        0, 0.84, 0.84, 1.0)
    gap = EnergyWindowMaterialGas('air gap', thickness=0.03)
    tint_glass = EnergyWindowMaterialGlazing(
        'Tinted Low-e Glass', 0.00318, 0.09, 0.359, 0.16, 0.207,
        0, 0.84, 0.046578, 1.0)
    window_constr = WindowConstruction('Double Low-E', [lowe_glass, gap, clear_glass])
    sched = ScheduleRuleset.from_daily_values(
        'NighSched', [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                      0, 0, 0, 0, 0, 1, 1, 1])
    double_low_e_ec = WindowConstructionShade(
        'Double Low-E Inside EC', window_constr, tint_glass, 'Exterior',
        'OnIfHighSolarOnWindow', 200, sched)
    double_low_e_between_ec = WindowConstructionShade(
        'Double Low-E Between EC', window_constr, tint_glass, 'Between')
    double_low_e_ext_ec = WindowConstructionShade(
        'Double Low-E Outside EC', window_constr, tint_glass, 'Interior')
    double_low_e_ec_dup = double_low_e_ec.duplicate()

    assert double_low_e_ec.identifier == 'Double Low-E Inside EC'
    assert double_low_e_ec.window_construction == \
        double_low_e_ec_dup.window_construction
    assert double_low_e_ec.shade_material == double_low_e_ec_dup.shade_material
    assert double_low_e_ec.shade_location == \
        double_low_e_ec_dup.shade_location == 'Exterior'
    assert double_low_e_ec.control_type == \
        double_low_e_ec_dup.control_type == 'OnIfHighSolarOnWindow'
    assert double_low_e_ec.setpoint == double_low_e_ec_dup.setpoint == 200
    assert double_low_e_ec.schedule == double_low_e_ec_dup.schedule == sched
    assert len(double_low_e_ec.materials) == 3
    assert len(double_low_e_ec.layers) == 3
    assert len(double_low_e_ec.unique_materials) == 4
    assert not double_low_e_ec.is_symmetric
    assert double_low_e_ec.is_switchable_glazing
    assert double_low_e_ec.has_shade
    assert double_low_e_ec.thickness == \
        double_low_e_ec.window_construction.thickness
    assert double_low_e_ec.glazing_count == 2
    assert double_low_e_ec.gap_count == 1

    assert double_low_e_between_ec.identifier == 'Double Low-E Between EC'
    assert double_low_e_between_ec.shade_location == 'Between'
    assert double_low_e_between_ec.control_type == 'AlwaysOn'
    assert double_low_e_between_ec.setpoint is None
    assert double_low_e_between_ec.schedule is None
    assert len(double_low_e_between_ec.materials) == 3
    assert len(double_low_e_between_ec.unique_materials) == 4
    assert not double_low_e_between_ec.is_symmetric
    assert double_low_e_between_ec.gap_count == 1

    assert double_low_e_ext_ec.identifier == 'Double Low-E Outside EC'
    assert len(double_low_e_ext_ec.materials) == 3
示例#18
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)
示例#19
0
def test_window_construction_init():
    """Test the initalization of WindowConstruction objects and basic properties."""
    lowe_glass = EnergyWindowMaterialGlazing('Low-e Glass', 0.00318, 0.4517,
                                             0.359, 0.714, 0.207, 0, 0.84,
                                             0.046578, 1.0)
    clear_glass = EnergyWindowMaterialGlazing('Clear Glass', 0.005715,
                                              0.770675, 0.07, 0.8836, 0.0804,
                                              0, 0.84, 0.84, 1.0)
    gap = EnergyWindowMaterialGas('air gap', thickness=0.0127)
    double_low_e = WindowConstruction('Double Low-E Window',
                                      [lowe_glass, gap, clear_glass])
    double_clear = WindowConstruction('Double Clear Window',
                                      [clear_glass, gap, clear_glass])
    triple_clear = WindowConstruction(
        'Triple Clear Window',
        [clear_glass, gap, clear_glass, gap, clear_glass])
    double_low_e_dup = double_low_e.duplicate()
    str(double_low_e)  # test the string representation of the construction

    assert double_low_e.name == double_low_e_dup.name == 'Double Low-E Window'
    assert len(double_low_e.materials) == len(double_low_e_dup.materials) == 3
    assert double_low_e.r_value == double_low_e_dup.r_value == \
        pytest.approx(0.41984, rel=1e-2)
    assert double_low_e.u_value == double_low_e_dup.u_value == \
        pytest.approx(2.3818, rel=1e-2)
    assert double_low_e.u_factor == double_low_e_dup.u_factor == \
        pytest.approx(1.69802, rel=1e-2)
    assert double_low_e.r_factor == double_low_e_dup.r_factor == \
        pytest.approx(0.588919, rel=1e-2)
    assert double_low_e.inside_emissivity == \
        double_low_e_dup.inside_emissivity == 0.84
    assert double_low_e.outside_emissivity == \
        double_low_e_dup.outside_emissivity == 0.84
    assert double_low_e.unshaded_solar_transmittance == \
        double_low_e_dup.unshaded_solar_transmittance == 0.4517 * 0.770675
    assert double_low_e.unshaded_visible_transmittance == \
        double_low_e_dup.unshaded_visible_transmittance == 0.714 * 0.8836
    assert double_low_e.glazing_count == double_low_e_dup.glazing_count == 2
    assert double_low_e.gap_count == double_low_e_dup.gap_count == 1
    assert double_low_e.has_shade is double_low_e_dup.has_shade is False
    assert double_low_e.shade_location is double_low_e_dup.shade_location is None

    assert double_clear.u_factor == pytest.approx(2.72, rel=1e-2)
    assert double_low_e.u_factor == pytest.approx(1.698, rel=1e-2)
    assert triple_clear.u_factor == pytest.approx(1.757, rel=1e-2)
示例#20
0
def test_window_construction_init_from_idf_file():
    """Test the initalization of WindowConstruction from file."""
    lbnl_window_idf_file = './tests/idf/GlzSys_Triple Clear_Avg.idf'
    glaz_constrs, glaz_mats = WindowConstruction.extract_all_from_idf_file(
        lbnl_window_idf_file)

    assert len(glaz_mats) == 2
    glaz_constr = glaz_constrs[0]
    constr_str = glaz_constr.to_idf()
    mat_str = [mat.to_idf() for mat in glaz_constr.unique_materials]
    new_glaz_constr = WindowConstruction.from_idf(constr_str, mat_str)
    new_constr_str = new_glaz_constr.to_idf()

    assert glaz_constr.name == new_glaz_constr.name == 'GlzSys_5'
    assert glaz_constr.u_factor == new_glaz_constr.u_factor == \
        pytest.approx(1.75728, rel=1e-2)
    assert glaz_constr.thickness == new_glaz_constr.thickness == \
        pytest.approx(0.0425, rel=1e-2)
    assert constr_str == new_constr_str
示例#21
0
def construction_window_blinds(directory):
    shade_mat = EnergyWindowMaterialBlind(
        'Plastic Blind', 'Vertical', 0.025, 0.01875, 0.003, 90, 0.2, 0.05, 0.4,
        0.05, 0.45, 0, 0.95, 0.1, 1)
    window_constr = WindowConstruction('Double Low-E', [lowe_glass, argon_gap, clear_glass])
    window_with_blinds = WindowConstructionShade(
        'Double Low-E Outside Shade', window_constr, shade_mat, 'Interior')
    dest_file = os.path.join(directory, 'construction_window_blinds.json')
    with open(dest_file, 'w') as fp:
        json.dump(window_with_blinds.to_dict(abridged=True), fp, indent=4)
示例#22
0
def construction_window_shade(directory):
    """Test the initialization of WindowConstructionShade objects with shades."""
    shade_mat = EnergyWindowMaterialShade(
        'Low-e Diffusing Shade', 0.025, 0.15, 0.5, 0.25, 0.5, 0, 0.4,
        0.2, 0.1, 0.75, 0.25)
    window_constr = WindowConstruction('Double Low-E', [lowe_glass, argon_gap, clear_glass])
    window_with_shade = WindowConstructionShade(
        'Double Low-E Outside Shade', window_constr, shade_mat, 'Interior')
    dest_file = os.path.join(directory, 'construction_window_shade.json')
    with open(dest_file, 'w') as fp:
        json.dump(window_with_shade.to_dict(abridged=True), fp, indent=4)
示例#23
0
def test_window_symmetric():
    """Test that the window construction is_symmetric property."""
    clear_glass = EnergyWindowMaterialGlazing('Clear Glass', 0.005715,
                                              0.770675, 0.07, 0.8836, 0.0804,
                                              0, 0.84, 0.84, 1.0)
    low_e_glass = EnergyWindowMaterialGlazing('Clear Glass', 0.005715,
                                              0.770675, 0.07, 0.8836, 0.0804,
                                              0, 0.84, 0.05, 1.0)
    gap = EnergyWindowMaterialGas('air gap', thickness=0.0127)
    double_low_e = WindowConstruction('Double Clear Window',
                                      [clear_glass, gap, low_e_glass])
    double_clear = WindowConstruction('Clear Window',
                                      [clear_glass, gap, clear_glass])
    single_clear = WindowConstruction('Clear Window', [clear_glass])
    triple_clear = WindowConstruction(
        'Clear Window', [clear_glass, gap, clear_glass, gap, clear_glass])

    assert not double_low_e.is_symmetric
    assert double_clear.is_symmetric
    assert single_clear.is_symmetric
    assert triple_clear.is_symmetric
示例#24
0
def test_run_idf_window_shade():
    """Test the Model.to.idf and run_idf method with a model that has a window shade."""
    # Get input Model
    room = Room.from_box('TinyHouseZone', 5, 10, 3)
    room.properties.energy.program_type = office_program
    room.properties.energy.add_default_ideal_air()

    double_clear = WindowConstruction('Double Pane Clear',
                                      [clear_glass, air_gap, clear_glass])
    shade_mat = EnergyWindowMaterialShade('Low-e Diffusing Shade', 0.005, 0.15,
                                          0.5, 0.25, 0.5, 0, 0.4, 0.2, 0.1,
                                          0.75, 0.25)
    sched = ScheduleRuleset.from_daily_values('NighSched', [
        1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1
    ])
    double_ec = WindowConstructionShade('Double Low-E Inside EC', double_clear,
                                        shade_mat, 'Interior',
                                        'OnIfHighSolarOnWindow', 200, sched)

    south_face = room[3]
    south_face.apertures_by_ratio(0.4, 0.01)
    south_face.apertures[0].properties.energy.construction = double_ec
    north_face = room[1]
    north_face.apertures_by_ratio(0.4, 0.01)

    model = Model('TinyHouse', [room])

    # Get the input SimulationParameter
    sim_par = SimulationParameter()
    sim_par.output.add_zone_energy_use()
    ddy_file = './tests/ddy/chicago.ddy'
    sim_par.sizing_parameter.add_from_ddy_996_004(ddy_file)
    sim_par.run_period.end_date = Date(1, 7)

    # create the IDF string for simulation paramters and model
    idf_str = '\n\n'.join((sim_par.to_idf(), model.to.idf(model)))

    # write the final string into an IDF
    idf = os.path.join(folders.default_simulation_folder, 'test_file_shd',
                       'in.idf')
    write_to_file(idf, idf_str, True)

    # prepare the IDF for simulation
    epw_file = './tests/simulation/chicago.epw'
    prepare_idf_for_simulation(idf, epw_file)

    # run the IDF through EnergyPlus
    sql, zsz, rdd, html, err = run_idf(idf, epw_file)

    assert os.path.isfile(sql)
    assert os.path.isfile(err)
    err_obj = Err(err)
    assert 'EnergyPlus Completed Successfully' in err_obj.file_contents
示例#25
0
def test_window_lockability():
    """Test the lockability of the window construction."""
    clear_glass = EnergyWindowMaterialGlazing('Clear Glass', 0.005715,
                                              0.770675, 0.07, 0.8836, 0.0804,
                                              0, 0.84, 0.84, 1.0)
    gap = EnergyWindowMaterialGas('air gap', thickness=0.0127)
    double_clear = WindowConstruction('Double Clear Window',
                                      [clear_glass, gap, clear_glass])

    double_clear.materials = [clear_glass, gap, clear_glass, gap, clear_glass]
    double_clear.lock()
    with pytest.raises(AttributeError):
        double_clear.materials = [clear_glass]
    with pytest.raises(AttributeError):
        double_clear[0].solar_transmittance = 0.45
    double_clear.unlock()
    double_clear.materials = [clear_glass]
    double_clear[0].solar_transmittance = 0.45
示例#26
0
def test_window_equivalency():
    """Test the equality of a window construction to another."""
    clear_glass = EnergyWindowMaterialGlazing('Clear Glass', 0.005715,
                                              0.770675, 0.07, 0.8836, 0.0804,
                                              0, 0.84, 0.84, 1.0)
    gap = EnergyWindowMaterialGas('air gap', thickness=0.0127)
    double_clear = WindowConstruction('Clear Window',
                                      [clear_glass, gap, clear_glass])
    double_clear_2 = double_clear.duplicate()
    triple_clear = WindowConstruction(
        'Clear Window', [clear_glass, gap, clear_glass, gap, clear_glass])
    double_clear_3 = WindowConstruction('Double Clear Window',
                                        [clear_glass, gap, clear_glass])

    collection = [double_clear, double_clear, double_clear_2, triple_clear]
    assert len(set(collection)) == 2
    assert double_clear == double_clear_2
    assert double_clear != triple_clear
    assert double_clear != double_clear_3

    double_clear_2.name = 'Cool Window'
    assert double_clear != double_clear_2
示例#27
0
def test_window_construction_init_gas_mixture():
    """Test the initalization of WindowConstruction objects with a gas mixture."""
    lowe_glass = EnergyWindowMaterialGlazing('Low-e Glass', 0.00318, 0.4517,
                                             0.359, 0.714, 0.207, 0, 0.84,
                                             0.046578, 1.0)
    clear_glass = EnergyWindowMaterialGlazing('Clear Glass', 0.005715,
                                              0.770675, 0.07, 0.8836, 0.0804,
                                              0, 0.84, 0.84, 1.0)
    air_argon = EnergyWindowMaterialGasMixture('Air Argon Gap', 0.0125,
                                               ('Air', 'Argon'), (0.1, 0.9))
    double_low_e_argon = WindowConstruction(
        'Double Low-E with Argon', [lowe_glass, air_argon, clear_glass])

    assert double_low_e_argon.u_factor == pytest.approx(1.46319708, rel=1e-2)
示例#28
0
def test_writer_to_idf():
    """Test the Model to.idf method."""
    room = Room.from_box('TinyHouseZone', 5, 10, 3)
    room.properties.energy.program_type = 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('OutdoorLightShelf', 0.5, 0.5)
    light_shelf_in = ShadeConstruction('IndoorLightShelf', 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('FrontDoor', 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('FrontAperture', 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('TreeCanopy', 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('TinyHouse', [room], orphaned_shades=[tree_canopy])

    assert hasattr(model.to, 'idf')
    idf_string = model.to.idf(model, schedule_directory='./tests/idf/')
示例#29
0
def test_from_dict():
    """Test the Aperture from_dict method with energy properties."""
    aperture = Aperture.from_vertices(
        'wall_window', [[0, 0, 0], [10, 0, 0], [10, 0, 10], [0, 0, 10]])
    clear_glass = EnergyWindowMaterialGlazing('Clear Glass', 0.005715,
                                              0.770675, 0.07, 0.8836, 0.0804,
                                              0, 0.84, 0.84, 1.0)
    gap = EnergyWindowMaterialGas('air gap', thickness=0.0127)
    triple_pane = WindowConstruction(
        'Triple Pane', [clear_glass, gap, clear_glass, gap, clear_glass])
    aperture.properties.energy.construction = triple_pane

    ad = aperture.to_dict()
    new_aperture = Aperture.from_dict(ad)
    assert new_aperture.properties.energy.construction == triple_pane
    assert new_aperture.to_dict() == ad
示例#30
0
def test_writer_to_idf():
    """Test the Aperture to_idf method."""
    aperture = Aperture.from_vertices(
        'wall_window', [[0, 0, 0], [10, 0, 0], [10, 0, 10], [0, 0, 10]])
    clear_glass = EnergyWindowMaterialGlazing('Clear Glass', 0.005715,
                                              0.770675, 0.07, 0.8836, 0.0804,
                                              0, 0.84, 0.84, 1.0)
    gap = EnergyWindowMaterialGas('air gap', thickness=0.0127)
    triple_pane = WindowConstruction(
        'TriplePane', [clear_glass, gap, clear_glass, gap, clear_glass])
    aperture.properties.energy.construction = triple_pane

    assert hasattr(aperture.to, 'idf')
    idf_string = aperture.to.idf(aperture)
    assert 'wall_window,' in idf_string
    assert 'FenestrationSurface:Detailed,' in idf_string
    assert 'TriplePane' in idf_string