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

    constr_from_lib = constr_lib.opaque_construction_by_identifier(
        constr_lib.OPAQUE_CONSTRUCTIONS[0])
    assert isinstance(constr_from_lib, OpaqueConstruction)

    constr_from_lib = constr_lib.opaque_construction_by_identifier(
        constr_lib.OPAQUE_CONSTRUCTIONS[12])
    assert isinstance(constr_from_lib, OpaqueConstruction)
Example #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)
Example #3
0
def opaque_constr(construction, input_name):
    """Get an OpaqueConstrucion from the library if it's a string."""
    if isinstance(construction, str):
        return opaque_construction_by_identifier(construction)
    else:
        assert isinstance(construction, OpaqueConstruction), \
            'Expected OpaqueConstruction for {}. Got {}'.format(
                input_name, type(construction))
    return construction
Example #4
0
def opaque_construction_by_id(construction_id, abridged, output_file):
    """Get an opaque construction definition from the standards lib with its identifier.
    \n
    Args:
        construction_id: The identifier of an opaque construction in the library.
    """
    try:
        output_file.write(json.dumps(opaque_construction_by_identifier(
            construction_id).to_dict(abridged=abridged)))
    except Exception as e:
        _logger.exception(
            'Retrieval from opaque construction library failed.\n{}'.format(e))
        sys.exit(1)
    else:
        sys.exit(0)
Example #5
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] = opaque_construction_by_identifier(constr)

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

    # assign the constructions
    if len(_constr) == 1:  # assign indiscriminately, even if it's horizontal
        for obj in hb_objs:
            if isinstance(obj, (Face, Door)):
                obj.properties.energy.construction = _constr[0]
            elif isinstance(obj, Room):
                for face in obj.faces:
                    if is_exterior_wall(face):
                        face.properties.energy.construction = _constr[0]
            else:
                raise TypeError(error_msg.format(type(obj)))
Example #6
0
    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))
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]
            ground conditions.
"""

ghenv.Component.Name = 'HB Ground'
ghenv.Component.NickName = 'Ground'
ghenv.Component.Message = '1.5.0'
ghenv.Component.Category = 'HB-Energy'
ghenv.Component.SubCategory = '0 :: Basic Properties'
ghenv.Component.AdditionalHelpFromDocStrings = '0'

try:  # import the honeybee-energy extension
    from honeybee_energy.lib.constructions import opaque_construction_by_identifier
except ImportError as e:
    raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e))

try:
    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):
    # duplicate rooms and process the construction
    rooms = [room.duplicate() for room in _rooms]
    _soil_constr_ = _soil_constr_ if _soil_constr_ is not None else 'Concrete Pavement'
    if isinstance(_soil_constr_, str):
        _soil_constr_ = opaque_construction_by_identifier(_soil_constr_)

    # loop through the rooms and convert them into ground objects
    for room in rooms:
        room.properties.energy.make_ground(_soil_constr_)
        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)
Example #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
Example #10
0
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.OPAQUE_CONSTRUCTIONS:
        constr_from_lib = constr_lib.opaque_construction_by_identifier(constr)
        assert isinstance(constr_from_lib,
                          (OpaqueConstruction, AirBoundaryConstruction))
Example #11
0
    if rad_mod_ is None:
        raise ValueError('rad_mod_ has been specified but honeybee-radiance '
                         'has failed to import.\n{}'.format(e))

if all_required_inputs(ghenv.Component):
    # process the inputs
    rooms = [room.duplicate()
             for room in _rooms]  # duplicate to avoid editing input
    guide_faces = [g for geo in _guide
                   for g in to_face3d(geo)]  # convert to lb geometry
    if type_ is not None and type_ not in face_types:
        type_ = face_types.by_name(type_)
    if bc_ is not None and bc_ not in boundary_conditions:
        bc_ = boundary_conditions.by_name(bc_)
    if isinstance(ep_constr_, str):
        ep_constr_ = opaque_construction_by_identifier(ep_constr_)
    if isinstance(rad_mod_, str):
        rad_mod_ = modifier_by_identifier(rad_mod_)

    # loop through the rooms and set the face properties
    for room in rooms:
        select_faces = room.faces_by_guide_surface(
            guide_faces, tolerance=tolerance, angle_tolerance=angle_tolerance)
        for hb_face in select_faces:
            if type_ is not None:
                hb_face.type = type_
            if bc_ is not None:
                hb_face.boundary_condition = bc_
            if ep_constr_ is not None:
                hb_face.properties.energy.construction = ep_constr_
            if rad_mod_ is not None: