Esempio n. 1
0
def test_air_construction_to_idf():
    """Test the initialization of AirBoundaryConstruction objects and basic properties."""
    night_flush = ScheduleRuleset.from_daily_values(
        'Night Flush', [1, 1, 1, 1, 1, 1, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,
                        0.5, 0.5, 0.5, 0.5, 0.5, 1, 1, 1])
    night_flush_constr = AirBoundaryConstruction('Night Flush Boundary', 0.4, night_flush)

    assert isinstance(night_flush_constr.to_idf(), str)
Esempio n. 2
0
def test_air_dict_methods():
    """Test the to/from dict methods."""
    night_flush = ScheduleRuleset.from_daily_values(
        'Night Flush', [1, 1, 1, 1, 1, 1, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,
                        0.5, 0.5, 0.5, 0.5, 0.5, 1, 1, 1])
    night_flush_constr = AirBoundaryConstruction('Night Flush Boundary', 0.4, night_flush)
    
    constr_dict = night_flush_constr.to_dict()
    new_constr = AirBoundaryConstruction.from_dict(constr_dict)
    assert night_flush_constr == new_constr
    assert constr_dict == new_constr.to_dict()
Esempio n. 3
0
def test_air_construction_init():
    """Test the initialization of AirBoundaryConstruction objects and basic properties."""
    default_constr = AirBoundaryConstruction('Default Air Construction')

    night_flush = ScheduleRuleset.from_daily_values(
        'Night Flush', [1, 1, 1, 1, 1, 1, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,
                        0.5, 0.5, 0.5, 0.5, 0.5, 1, 1, 1])
    night_flush_constr = AirBoundaryConstruction('Night Flush Boundary', 0.4, night_flush)
    str(night_flush_constr)  # test the string representation of the construction

    constr_dup = night_flush_constr.duplicate()

    assert night_flush_constr.identifier == constr_dup.identifier == 'Night Flush Boundary'
    assert night_flush_constr.air_mixing_per_area == constr_dup.air_mixing_per_area == 0.4
    assert night_flush_constr.air_mixing_schedule == constr_dup.air_mixing_schedule
Esempio n. 4
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))
Esempio n. 5
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))
Esempio n. 6
0
def test_air_equivalency():
    """Test the equality of a AirBoundaryConstruction to another."""
    default_constr = AirBoundaryConstruction('Default Air Construction')

    night_flush = ScheduleRuleset.from_daily_values(
        'Night Flush', [1, 1, 1, 1, 1, 1, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,
                        0.5, 0.5, 0.5, 0.5, 0.5, 1, 1, 1])
    night_flush_constr = AirBoundaryConstruction(
        'Night Flush Boundary', 0.4, night_flush)
    night_flush_constr_dup = night_flush_constr.duplicate()

    assert night_flush_constr is night_flush_constr
    assert night_flush_constr is not night_flush_constr_dup
    assert night_flush_constr == night_flush_constr_dup
    assert default_constr != night_flush_constr
    assert hash(night_flush_constr) == hash(night_flush_constr_dup)
    assert hash(default_constr) != hash(night_flush_constr)

    collection = [default_constr, night_flush_constr, night_flush_constr_dup]
    assert len(set(collection)) == 2
Esempio n. 7
0
def dict_abridged_to_construction(constr_dict,
                                  materials,
                                  schedules,
                                  raise_exception=True):
    """Get a Python object of any Construction from an abridged dictionary.

    Args:
        constr_dict: An abridged dictionary of any Honeybee energy construction.
        materials: Dictionary of all material objects that might be used in the
            construction with the material identifiers as the keys.
        schedules: Dictionary of all schedule objects that might be used in the
            construction with the schedule identifiers as the keys.
        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 == 'OpaqueConstructionAbridged':
        return OpaqueConstruction.from_dict_abridged(constr_dict, materials)
    elif constr_type == 'WindowConstructionAbridged':
        return WindowConstruction.from_dict_abridged(constr_dict, materials)
    elif constr_type == 'WindowConstructionShade':
        return WindowConstructionShade.from_dict_abridged(
            constr_dict, materials, schedules)
    elif constr_type == 'ShadeConstruction':
        return ShadeConstruction.from_dict(constr_dict)
    elif constr_type == 'AirBoundaryConstructionAbridged':
        return AirBoundaryConstruction.from_dict_abridged(
            constr_dict, schedules)
    elif constr_type == 'AirBoundaryConstruction':  # special case for ConstructionSet
        return AirBoundaryConstruction.from_dict(constr_dict)
    elif raise_exception:
        raise ValueError(
            '{} is not a recognized energy Construction type'.format(
                constr_type))
Esempio n. 8
0
def test_dict_to_object_construction():
    """Test the dict_to_object method with AirBoundaryConstruction objects."""
    construction_obj = AirBoundaryConstruction('Test Air Wall')
    construction_dict = construction_obj.to_dict()
    new_construction = dict_to_object(construction_dict)
    assert isinstance(new_construction, AirBoundaryConstruction)