Exemplo n.º 1
0
def test_clean_ep_string():
    """Test the clean_ep_string method."""
    correct_str = '1/2 in. Gypsum Board'
    incorrect_str = '1/2 in., Gypsum Board!'
    long_str = 'This is an exceptionally long text string that should never be used ' \
        'for the name of anything in EnergyPlus'

    assert clean_ep_string(correct_str) == correct_str
    assert clean_ep_string(incorrect_str) == correct_str
    with pytest.raises(AssertionError):
        clean_ep_string(long_str)
try:  # import the honeybee-energy dependencies
    from honeybee_energy.constructionset import ConstructionSet
    from honeybee_energy.lib.constructionsets import construction_set_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):
    # get the base construction set
    name = clean_and_id_ep_string('ConstructionSet') if _name_ is None else \
        clean_ep_string(_name_)
    if base_constr_set_ is None:
        constr_set = ConstructionSet(name)
    else:
        if isinstance(base_constr_set_, str):
            base_constr_set_ = construction_set_by_identifier(base_constr_set_)
        constr_set = base_constr_set_.duplicate()
        constr_set.identifier = name
        if _name_ is not None:
            constr_set.display_name = _name_

    # go through each input construction subset and assign it to the set
    if len(_exterior_subset_) != 0:
        assert len(
            _exterior_subset_) == 3, 'Input _exterior_subset_ is not valid.'
        if _exterior_subset_[0] is not None:
ghenv.Component.Name = 'DF Electrical Network'
ghenv.Component.NickName = 'Network'
ghenv.Component.Message = '1.2.0'
ghenv.Component.Category = 'Dragonfly'
ghenv.Component.SubCategory = '3 :: Energy'
ghenv.Component.AdditionalHelpFromDocStrings = '0'

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

try:  # import the core dragonfly_energy dependencies
    from dragonfly_energy.opendss.network import ElectricalNetwork
except ImportError as e:
    raise ImportError('\nFailed to import dragonfly_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):
    # set a default name
    name = clean_ep_string(_name_) if _name_ is not None else 'unnamed'

    # create the model
    network = ElectricalNetwork(name, _substation, _transformers, _connectors)
    if _name_ is not None:
        network.display_name = _name_
Exemplo n.º 4
0
if all_required_inputs(ghenv.Component):
    # duplicate the initial objects
    df_objs = [obj.duplicate() for obj in _df_objs]

    # process any input properties for the HVAC system
    try:  # get the class for the HVAC system
        try:
            _sys_name = hvac_dict[_system_type]
        except KeyError:
            _sys_name = _system_type
        hvac_class = EQUIPMENT_TYPES_DICT[_sys_name]
    except KeyError:
        raise ValueError('System Type "{}" is not recognized as a HeatCool HVAC '
                         'system.'.format(_system_type))
    vintage = vintages[_vintage_]  # get the vintage of the HVAC
    name = clean_and_id_ep_string('Heat-Cool HVAC') if _name_ is None else clean_ep_string(_name_)

    # create the HVAC
    hvac = hvac_class(name, vintage, _sys_name)
    if _name_ is not None:
        hvac.display_name = _name_

    # apply the HVAC system to the objects
    for obj in df_objs:
        if isinstance(obj, (Building, Story)):
            obj.properties.energy.set_all_room_2d_hvac(hvac)
        elif isinstance(obj, Room2D) and obj.properties.energy.is_conditioned:
            obj.properties.energy.hvac = hvac
        elif isinstance(obj, Model):
            for bldg in obj.buildings:
                bldg.properties.energy.set_all_room_2d_hvac(hvac)
        _construction = opaque_construction_by_identifier(_construction)

    # determine whether the input _geo_or_area is geometry or floats
    try:
        areas = [float(num) for num in _geo_or_area]
    except AttributeError:  # assume that the input is a list of geometry
        geo = [f for geo in _geo_or_area for f in to_face3d(geo)]
        conversion = conversion_to_meters()**2
        areas = [0 for room in rooms]
        for i, room in enumerate(rooms):
            for face in geo:
                if room.geometry.is_point_inside(face.center):
                    areas[i] += face.area * conversion

    # create the internal mass objects and assign them to the rooms
    for i, room in enumerate(rooms):
        area = longest_list(areas, i)
        if area != 0:
            if len(_name_) == 0:  # make a default Room name
                display_name = 'Internal Mass {}'.format(
                    document_counter('mass_count'))
            else:
                display_name = '{}_{}'.format(longest_list(_name_, i), i + 1) \
                    if len(_name_) != len(_rooms) else longest_list(_name_, i)
            name = clean_ep_string(display_name)
            mass = InternalMass(name, _construction, area)
            mass.display_name = display_name
            room.properties.energy.add_internal_mass(mass)
            print('Internal mass with area {} m2 has been added to room '
                  '"{}"'.format(round(area, 3), room.display_name))
Exemplo n.º 6
0
            raise ValueError('Expected Honeybee Room or Model. Got {}.'.format(
                type(hb_obj)))

    # process any input properties for the HVAC system
    try:  # get the class for the HVAC system
        try:
            _sys_name = hvac_dict[_system_type]
        except KeyError:
            _sys_name = _system_type
        hvac_class = EQUIPMENT_TYPES_DICT[_sys_name]
    except KeyError:
        raise ValueError('System Type "{}" is not recognized as a DOAS HVAC '
                         'system.'.format(_system_type))
    vintage = vintages[_vintage_]  # get the vintage of the HVAC
    name = clean_and_id_ep_string(
        'DOAS HVAC') if _name_ is None else clean_ep_string(_name_)

    # create the HVAC
    hvac = hvac_class(name, vintage, _sys_name, sensible_hr_, latent_hr_, dcv_)
    if doas_avail_sch_ is not None:
        if isinstance(doas_avail_sch_, str):
            doas_avail_sch_ = schedule_by_identifier(doas_avail_sch_)
        hvac.doas_availability_schedule = doas_avail_sch_
    if _name_ is not None:
        hvac.display_name = _name_

    # apply the HVAC system to the rooms
    vent_scheds = set()
    hvac_count = 0
    for room in rooms:
        if room.properties.energy.is_conditioned:
                type(hb_obj)))

    # process any input properties for the HVAC system
    try:  # get the class for the HVAC system
        try:
            _sys_name = hvac_dict[_system_type]
        except KeyError:
            _sys_name = _system_type
        hvac_class = EQUIPMENT_TYPES_DICT[_sys_name]
    except KeyError:
        raise ValueError(
            'System Type "{}" is not recognized as a HeatCool HVAC '
            'system.'.format(_system_type))
    vintage = vintages[_vintage_]  # get the vintage of the HVAC
    name = clean_and_id_ep_string(
        'Heat-Cool HVAC') if _name_ is None else clean_ep_string(_name_)

    # create the HVAC
    hvac = hvac_class(name, vintage, _sys_name)
    if _name_ is not None:
        hvac.display_name = _name_

    # apply the HVAC system to the rooms
    hvac_count = 0
    for room in rooms:
        if room.properties.energy.is_conditioned:
            room.properties.energy.hvac = hvac
            hvac_count += 1

    # give a warning if no rooms were conditioned
    if hvac_count == 0:
    df_objs = [obj.duplicate() for obj in _df_objs]

    # process any input properties for the HVAC system
    try:  # get the class for the HVAC system
        try:
            _sys_name = hvac_dict[_system_type]
        except KeyError:
            _sys_name = _system_type
        hvac_class = EQUIPMENT_TYPES_DICT[_sys_name]
    except KeyError:
        raise ValueError(
            'System Type "{}" is not recognized as an all-air HVAC '
            'system.'.format(_system_type))
    vintage = vintages[_vintage_]  # get the vintage of the HVAC
    name = clean_and_id_ep_string(
        'All-Air HVAC') if _name_ is None else clean_ep_string(_name_)

    # create the HVAC
    hvac = hvac_class(name, vintage, _sys_name)
    if _economizer_ is not None:
        hvac.economizer_type = _economizer_
    if sensible_hr_ is not None:
        hvac.sensible_heat_recovery = sensible_hr_
    if latent_hr_ is not None:
        hvac.latent_heat_recovery = latent_hr_
    if dcv_:
        hvac.demand_controlled_ventilation = True
    if _name_ is not None:
        hvac.display_name = _name_

    # apply the HVAC system to the objects
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

if all_required_inputs(ghenv.Component):
    # duplicate the initial objects
    rooms = [room.duplicate() for room in _rooms]

    # set default values and check the inputs
    use_category_ = ['Process'] if len(use_category_) == 0 else use_category_
    radiant_fract_ = [0.0] if len(radiant_fract_) == 0 else radiant_fract_
    latent_fract_ = [0.0] if len(latent_fract_) == 0 else latent_fract_
    lost_fract_ = [0.0] if len(lost_fract_) == 0 else lost_fract_
    for i, sched in enumerate(_schedule):
        if isinstance(sched, str):
            _schedule[i] = schedule_by_identifier(sched)

    # loop through the rooms and assign process loads
    for i, room in enumerate(rooms):
        load_watts = longest_list(_watts, i)
        if load_watts != 0:
            name = clean_and_id_ep_string('Process') if len(_name_) == 0 else \
                clean_ep_string(longest_list(_name_, i))
            process = Process('{}..{}'.format(name, room.identifier),
                              load_watts, longest_list(_schedule, i),
                              longest_list(_fuel_type, i),
                              longest_list(use_category_, i),
                              longest_list(radiant_fract_, i),
                              longest_list(latent_fract_, i),
                              longest_list(lost_fract_, i))
            room.properties.energy.add_process_load(process)