def test_construction_lib():
    """Test that the honeybee-energy lib has been extended with new construction data."""
    assert len(constr_lib.WINDOW_CONSTRUCTIONS
               ) > 2  # should now have many more constructions

    constr_from_lib = constr_lib.window_construction_by_identifier(
        constr_lib.WINDOW_CONSTRUCTIONS[0])
    assert isinstance(constr_from_lib, WindowConstruction)

    constr_from_lib = constr_lib.window_construction_by_identifier(
        constr_lib.WINDOW_CONSTRUCTIONS[2])
    assert isinstance(constr_from_lib, WindowConstruction)
예제 #2
0
def constructions_by_id(construction_ids, complete, output_file):
    """Get several construction definitions from the standards lib at once.

    \b
    Args:
        construction_ids: Any number of construction identifiers to be retrieved
            from the library.
    """
    try:
        abridged = not complete
        cons = []
        for con_id in construction_ids:
            try:
                cons.append(
                    opaque_construction_by_identifier(con_id).to_dict(
                        abridged=abridged))
            except ValueError:
                try:
                    cons.append(
                        window_construction_by_identifier(con_id).to_dict(
                            abridged=abridged))
                except ValueError:
                    cons.append(
                        shade_construction_by_identifier(con_id).to_dict())
        output_file.write(json.dumps(cons))
    except Exception as e:
        _logger.exception(
            'Retrieval from construction library failed.\n{}'.format(e))
        sys.exit(1)
    else:
        sys.exit(0)
예제 #3
0
def window_constr(construction, input_name):
    """Get an WindowConstrucion from the library if it's a string."""
    if isinstance(construction, str):
        return window_construction_by_identifier(construction)
    else:
        win_cls = (WindowConstruction, WindowConstructionShade, WindowConstructionDynamic)
        assert isinstance(construction, win_cls), 'Expected WindowConstruction ' \
            'for {}. Got {}'.format(input_name, type(construction))
    return construction
예제 #4
0
def window_constr(construction, input_name):
    """Get a WindowConstrucion from the library if it's a string."""
    if isinstance(construction, str):
        return window_construction_by_identifier(construction)
    else:
        assert isinstance(construction, WindowConstruction), \
            'Expected WindowConstruction for {}. Got {}'.format(
                input_name, type(construction))
    return construction
예제 #5
0
def window_construction_by_id(construction_id, abridged, output_file):
    """Get a window construction definition from the standards lib with its identifier.
    \n
    Args:
        construction_id: The identifier of a window construction in the library.
    """
    try:
        output_file.write(json.dumps(window_construction_by_identifier(
            construction_id).to_dict(abridged=abridged)))
    except Exception as e:
        _logger.exception(
            'Retrieval from window construction library failed.\n{}'.format(e))
        sys.exit(1)
    else:
        sys.exit(0)
예제 #6
0

def is_exterior_wall(face):
    """Check whether a given Face is an exterior Wall."""
    return isinstance(face.boundary_condition, Outdoors) and \
        isinstance(face.type, Wall)


if all_required_inputs(ghenv.Component):
    # duplicate the initial objects
    hb_objs = [obj.duplicate() for obj in _hb_objs]

    # process the input constructions
    for i, constr in enumerate(_constr):
        if isinstance(constr, str):
            _constr[i] = window_construction_by_identifier(constr)

    # error message for unrecognized object
    error_msg = 'Input _hb_objs must be a Room, Face, Aperture, or Door. Not {}.'

    # assign the constructions
    if len(_constr
           ) == 1:  # assign indiscriminately, even if it's a horizontal object
        for obj in hb_objs:
            if isinstance(obj, (Aperture, Door)):
                obj.properties.energy.construction = _constr[0]
            elif isinstance(obj, Face):
                for ap in obj.apertures:
                    ap.properties.energy.construction = _constr[0]
            elif isinstance(obj, Room):
                for face in obj.faces:
예제 #7
0
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))
try:
    from ladybug.datatype.rvalue import RValue
    from ladybug.datatype.uvalue import UValue
except ImportError as e:
    raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e))

if all_required_inputs(ghenv.Component):
    # check the input
    if isinstance(_constr, str):
        try:
            _constr = opaque_construction_by_identifier(_constr)
        except ValueError:
            _constr = window_construction_by_identifier(_constr)
    else:
        assert isinstance(_constr, (OpaqueConstruction, WindowConstruction)), \
            'Expected OpaqueConstruction or WindowConstruction. ' \
            'Got {}.'.format(type(_constr))

    # get the materials, r-value and u-factor
    materials = _constr.materials
    layers = _constr.layers
    r_val_si = _constr.r_value
    r_val_ip = RValue().to_ip([r_val_si], 'm2-K/W')[0][0]
    u_fac_si = _constr.u_factor
    u_fac_ip = UValue().to_ip([u_fac_si], 'W/m2-K')[0][0]

    # get the transmittance
    if isinstance(_constr, WindowConstruction):
        else:
            display_name = '{}_{}'.format(longest_list(_name_, j), j + 1) \
                if len(_name_) != len(_geo) else longest_list(_name_, j)
            name = clean_and_id_string(display_name)
        glass = longest_list(glass_, j) if len(glass_) != 0 else False

        lb_faces = to_face3d(geo)
        for i, lb_face in enumerate(lb_faces):
            dr_name = '{}_{}'.format(name, i) if len(lb_faces) > 1 else name
            hb_dr = Door(dr_name, lb_face, is_glass=glass)
            hb_dr.display_name = display_name

            # try to assign the energyplus construction
            if len(ep_constr_) != 0:
                ep_constr = longest_list(ep_constr_, j)
                if isinstance(ep_constr, str):
                    ep_constr = opaque_construction_by_identifier(ep_constr) if not \
                        hb_dr.is_glass else window_construction_by_identifier(ep_constr)
                hb_dr.properties.energy.construction = ep_constr

            # try to assign the radiance modifier
            if len(rad_mod_) != 0:
                rad_mod = longest_list(rad_mod_, j)
                if isinstance(rad_mod, str):
                    rad_mod = modifier_by_identifier(rad_mod)
                hb_dr.properties.radiance.modifier = rad_mod

            doors.append(hb_dr)  # collect the final Doors
            i += 1  # advance the iterator
    doors = wrap_output(doors)
예제 #9
0
def from_standards_dict(cls, data):
    """Create a ConstructionSet from an OpenStudio standards gem dictionary.

    Args:
        data: An OpenStudio standards dictionary of a construction type in the
            format below.

    .. code-block:: python

        {
        "name": "2013::ClimateZone5::SteelFramed",
        "wall_set": {
            "exterior_construction": "Typical Insulated Steel Framed Exterior Wall-R19",
            "ground_construction": "Typical Insulated Basement Mass Wall-R8"
        },
        "floor_set": {
            "exterior_construction": "Typical Insulated Steel Framed Exterior Floor-R27",
            "ground_construction": "Typical Insulated Carpeted 8in Slab Floor-R5"
        },
        "roof_ceiling_set": {
            "exterior_construction": "Typical IEAD Roof-R32"
        },
        "aperture_set": {
            "window_construction": "U 0.48 SHGC 0.40 Dbl Ref-D Clr 6mm/13mm",
            "operable_construction": "U 0.48 SHGC 0.40 Dbl Ref-D Clr 6mm/13mm",
            "skylight_construction": "Window_U_0.50_SHGC_0.40_Skylight_Frame_Width_0.430_in"
        },
        "door_set": {
            "exterior_construction": "Typical Insulated Metal Door-R2",
            "overhead_construction": "Typical Overhead Door-R2",
            "exterior_glass_construction": "U 0.44 SHGC 0.26 Dbl Ref-B-H Clr 6mm/13mm Air"
        }
    """
    # initialize a blank construction set
    construction_set = cls(data['name'])

    # assign all of the opaque constructions
    construction_set.wall_set.exterior_construction = \
        con_lib.opaque_construction_by_identifier(data['wall_set']['exterior_construction'])
    construction_set.wall_set.ground_construction = \
        con_lib.opaque_construction_by_identifier(data['wall_set']['ground_construction'])
    construction_set.floor_set.exterior_construction = \
        con_lib.opaque_construction_by_identifier(data['floor_set']['exterior_construction'])
    construction_set.floor_set.ground_construction = \
        con_lib.opaque_construction_by_identifier(data['floor_set']['ground_construction'])
    construction_set.roof_ceiling_set.exterior_construction = \
        con_lib.opaque_construction_by_identifier(data['roof_ceiling_set']['exterior_construction'])
    construction_set.door_set.exterior_construction = \
        con_lib.opaque_construction_by_identifier(data['door_set']['exterior_construction'])
    construction_set.door_set.overhead_construction = \
        con_lib.opaque_construction_by_identifier(data['door_set']['overhead_construction'])

    # assign all of the window constructions
    construction_set.aperture_set.window_construction = \
        con_lib.window_construction_by_identifier(data['aperture_set']['window_construction'])
    construction_set.aperture_set.operable_construction = \
        con_lib.window_construction_by_identifier(data['aperture_set']['operable_construction'])
    construction_set.aperture_set.skylight_construction = \
        con_lib.window_construction_by_identifier(data['aperture_set']['skylight_construction'])
    construction_set.door_set.exterior_glass_construction = \
        con_lib.window_construction_by_identifier(data['door_set']['exterior_glass_construction'])

    return construction_set
    'OnNightIfLowInsideTempAndOffDay': 'OnNightIfLowInsideTempAndOffDay',
    'OnNightIfHeatingAndOffDay': 'OnNightIfHeatingAndOffDay'
}

if all_required_inputs(ghenv.Component):
    # set default values
    constr_id = clean_and_id_ep_string('ShadedWindowConstruction') if _name_ is None else \
        clean_ep_string(_name_)
    _shd_location_ = 'Interior' if _shd_location_ is None else _shd_location_.title(
    )
    _control_type_ = 'AlwaysOn' if _control_type_ is None \
        else CONTROL_TYPES[_control_type_]

    # get objects from the library if they are strings
    if isinstance(_win_constr, str):
        win_con = window_construction_by_identifier(_win_constr)
        # duplicate and rename to avoid having the same construction name in one model
        _win_constr = win_con.duplicate()
        _win_constr.identifier = '{}_Unshaded'.format(constr_id)
    if isinstance(_shd_material, str):
        _shd_material = window_material_by_identifier(_shd_material)
    if isinstance(schedule_, str):
        schedule_ = schedule_by_identifier(schedule_)

    # create the construction object
    constr = WindowConstructionShade(constr_id, _win_constr, _shd_material,
                                     _shd_location_, _control_type_, setpoint_,
                                     schedule_)
    if _name_ is not None:
        constr.display_name = _name_
def test_opaque_material_by_identifier():
    """Test that all of the constructions in the library can be loaded by identifier."""
    for constr in constr_lib.WINDOW_CONSTRUCTIONS:
        constr_from_lib = constr_lib.window_construction_by_identifier(constr)
        assert isinstance(constr_from_lib, WindowConstruction)
try:  # import the honeybee-energy dependencies
    from honeybee_energy.construction.dynamic import WindowConstructionDynamic
    from honeybee_energy.lib.constructions import window_construction_by_identifier
    from honeybee_energy.lib.schedules import schedule_by_identifier
except ImportError as e:
    raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e))

try:  # import ladybug_rhino dependencies
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))


if all_required_inputs(ghenv.Component):
    name = clean_and_id_ep_string('DynamicWindowConstruction') if _name_ is None else \
        clean_ep_string(_name_)

    # get objects from the library if they are strings
    constr_objs = []
    for con in _constructions:
        if isinstance(con, str):
            con = window_construction_by_identifier(con)
        constr_objs.append(con)
    if isinstance(_schedule, str):
        _schedule = schedule_by_identifier(_schedule)

    # create the construction object
    constr = WindowConstructionDynamic(name, constr_objs, _schedule)
    if _name_ is not None:
        constr.display_name = _name_