Beispiel #1
0
def test_material_lib():
    """Test that the honeybee-energy lib has been extended with new material data."""
    possible_types = (EnergyMaterial, EnergyMaterialNoMass)

    assert len(mat_lib.OPAQUE_MATERIALS) > 13  # should now have many more materials

    mat_from_lib = mat_lib.opaque_material_by_identifier(mat_lib.OPAQUE_MATERIALS[0])
    assert isinstance(mat_from_lib, possible_types)

    mat_from_lib = mat_lib.opaque_material_by_identifier(mat_lib.OPAQUE_MATERIALS[13])
    assert isinstance(mat_from_lib, possible_types)
Beispiel #2
0
def opaque_construction_by_identifier(construction_identifier):
    """Get an opaque construction from the library given the construction identifier.

    Args:
        construction_identifier: A text string for the identifier of the construction.
    """
    try:
        return _opaque_constructions[construction_identifier]
    except KeyError:
        try:  # search the extension data
            constr_dict = _opaque_constr_standards_dict[
                construction_identifier]
            if constr_dict['type'] == 'OpaqueConstructionAbridged':
                mats = {}
                mat_key = 'layers' if 'layers' in constr_dict else 'materials'
                for mat in constr_dict[mat_key]:
                    mats[mat] = _m.opaque_material_by_identifier(mat)
                return OpaqueConstruction.from_dict_abridged(constr_dict, mats)
            else:  # AirBoundaryConstruction
                try:
                    sch_id = constr_dict['air_mixing_schedule']
                    schs = {sch_id: _s.schedule_by_identifier(sch_id)}
                except KeyError:  # no air mixing key provided
                    schs = {}
                return AirBoundaryConstruction.from_dict_abridged(
                    constr_dict, schs)
        except KeyError:  # construction is nowhere to be found; raise an error
            raise ValueError(
                '"{}" was not found in the opaque energy construction library.'
                .format(construction_identifier))
Beispiel #3
0
def test_opaque_material_by_identifier():
    """Test that all of the materials in the library can be loaded by identifier."""
    possible_types = (EnergyMaterial, EnergyMaterialNoMass)

    for mat in mat_lib.OPAQUE_MATERIALS:
        mat_from_lib = mat_lib.opaque_material_by_identifier(mat)
        assert isinstance(mat_from_lib, possible_types)
def from_standards_dict(cls, data):
    """Create an OpaqueConstruction from an OpenStudio standards gem dictionary.

    Args:
        data: An OpenStudio standards dictionary of an opaque construction in the
            format below.

    .. code-block:: json

        {
        "name": "Typical Insulated Exterior Mass Wall",
        "intended_surface_type": "ExteriorWall",
        "standards_construction_type": "Mass",
        "insulation_layer": "Typical Insulation",
        "materials": [
            "1IN Stucco",
            "8IN CONCRETE HW RefBldg",
            "Typical Insulation",
            "1/2IN Gypsum"]
        }
    """
    materials = tuple(
        mat_lib.opaque_material_by_identifier(mat)
        for mat in data['materials'])
    return cls(data['name'], materials)
def opaque_material_by_id(material_id, output_file):
    """Get an opaque material definition from the standards lib with its identifier.
    \n
    Args:
        material_id: The identifier of an opaque material in the library.
    """
    try:
        output_file.write(json.dumps(opaque_material_by_identifier(material_id).to_dict()))
    except Exception as e:
        _logger.exception(
            'Retrieval from opaque material library failed.\n{}'.format(e))
        sys.exit(1)
    else:
        sys.exit(0)
def materials_by_id(material_ids, output_file):
    """Get several material definitions from the standards lib at once.
    \n
    Args:
        material_ids: A list of material identifiers to be retrieved from the library.
    """
    try:
        mats = []
        for mat_id in material_ids:
            try:
                mats.append(opaque_material_by_identifier(mat_id))
            except ValueError:
                mats.append(window_material_by_identifier(mat_id))
        output_file.write(json.dumps([mat.to_dict() for mat in mats]))
    except Exception as e:
        _logger.exception(
            'Retrieval from material library failed.\n{}'.format(e))
        sys.exit(1)
    else:
        sys.exit(0)
Beispiel #7
0
ghenv.Component.Message = '0.1.2'
ghenv.Component.Category = 'HB-Energy'
ghenv.Component.SubCategory = "1 :: Constructions"
ghenv.Component.AdditionalHelpFromDocStrings = "4"

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.opaque import OpaqueConstruction
    from honeybee_energy.lib.materials import opaque_material_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):
    material_objs = []
    for material in _materials:
        if isinstance(material, str):
            material = opaque_material_by_identifier(material)
        material_objs.append(material)

    constr = OpaqueConstruction(clean_and_id_ep_string(_name), material_objs)
    constr.display_name = _name
    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(_mat, str):
        try:
            _mat = opaque_material_by_identifier(_mat)
        except ValueError:
            _mat = window_material_by_identifier(_mat)

    # get the values and attribute names
    mat_str = str(_mat)
    values = parse_idf_string(mat_str)
    attr_name_pattern1 = re.compile(r'!- (.*)\n')
    attr_name_pattern2 = re.compile(r'!- (.*)$')
    attr_names = attr_name_pattern1.findall(mat_str) + \
        attr_name_pattern2.findall(mat_str)

    # get the r-value
    try:
        r_val_si = _mat.r_value
        r_val_ip = RValue().to_ip([r_val_si], 'm2-K/W')[0][0]