Exemplo n.º 1
0
def test_clean_ep_string():
    """Test the clean_and_id_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_and_id_ep_string(correct_str).startswith(correct_str)
    assert clean_and_id_ep_string(incorrect_str).startswith(correct_str)
    assert len(clean_and_id_ep_string(long_str)) < 70
Exemplo n.º 2
0
def create_std_mass_material():
    ''' Simple 'Mass' Layer for inside/outside of simple constuctions '''

    try:
        # Set the default material properties
        roughness = 'MediumRough'
        therm_absp = 0.9
        sol_absp = 0.7
        vis_absp = 0.7
        name = 'MASSLAYER'
        thickness = 0.0254
        conductivity = 2
        density = 2500
        spec_heat = 460

        # Create the material
        mat = EnergyMaterial(clean_and_id_ep_string(name), thickness,
                             conductivity, density, spec_heat, roughness,
                             therm_absp, sol_absp, vis_absp)
        mat.display_name = name

        return mat
    except Exception as e:
        print('Error creating HB Material', e)
        return None
Exemplo n.º 3
0
def create_EP_const(_win_EP_material):
    """ Creates an 'E+' style construction for the window

    Args:
        _win_EP_material (): The E+ Material for the window
    Returns:
        constr (): The new E+ Construction for the window
    """

    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.window import WindowConstruction
        from honeybee_energy.lib.materials import window_material_by_identifier
    except ImportError as e:
        raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e))
    
    material_objs = []
    for material in [_win_EP_material]:
        if isinstance(material, str):
            material = window_material_by_identifier(material)
        material_objs.append(material)
    
    name = 'PHPP_CONST_{}'.format(_win_EP_material.display_name)

    constr = WindowConstruction(clean_and_id_ep_string(name), material_objs)
    constr.display_name = name

    return constr
Exemplo n.º 4
0
def create_hb_constant_schedule(_name, _type_limit='Fractional'):
    type_limit = schedule_type_limit_by_identifier( _type_limit )

    schedule = ScheduleRuleset.from_constant_value(
        clean_and_id_ep_string(_name), 1, type_limit)

    schedule.display_name = _name

    return schedule
Exemplo n.º 5
0
def create_HB_construction(_name, _layers):
    ''' Builds a HB Style Construction Object from a list of HB-Material layers'''

    try:
        constr = OpaqueConstruction(clean_and_id_ep_string(_name), _layers)
        constr.display_name = _name
        return constr
    except Exception as e:
        print('Error creating Construction', e)
        return None
Exemplo n.º 6
0
    def diversify(self,
                  count,
                  schedule_offset=1,
                  timestep=1,
                  schedule_indices=None):
        """Get an array of diversified Setpoints derived from this "average" one.

        Approximately 2/3 of the schedules in the output objects will be offset
        from the mean by the input schedule_offset (1/3 ahead and another 1/3 behind).

        Args:
            count: An positive integer for the number of diversified objects to
                generate from this mean object.
            schedule_offset: A positive integer for the number of timesteps at which
                the setpoint schedule of the resulting objects will be shifted - roughly
                1/3 of the objects ahead and another 1/3 behind. (Default: 1).
            timestep: An integer for the number of timesteps per hour at which the
                shifting is occurring. This must be a value between 1 and 60, which
                is evenly divisible by 60. 1 indicates that each step is an hour
                while 60 indicates that each step is a minute. (Default: 1).
            schedule_indices: An optional list of integers from 0 to 2 with a length
                equal to the input count, which will be used to set whether a given
                schedule is behind (0), ahead (2), or the same (1). This can be
                used to coordinate schedules across diversified programs. If None
                a random list of integers will be genrated. (Default: None).
        """
        # generate shifted schedules
        heats = self._shift_schedule(self.heating_schedule, schedule_offset,
                                     timestep)
        cools = self._shift_schedule(self.cooling_schedule, schedule_offset,
                                     timestep)
        if self.humidifying_schedule is not None:
            humids = self._shift_schedule(self.humidifying_schedule,
                                          schedule_offset, timestep)
            dehumids = self._shift_schedule(self.dehumidifying_schedule,
                                            schedule_offset, timestep)
        if schedule_indices is None:
            schedule_indices = [random.randint(0, 2) for i in range(count)]

        # generate the new objects and return them
        new_objects = []
        for sch_int in schedule_indices:
            new_obj = self.duplicate()
            new_obj.identifier = clean_and_id_ep_string(self.identifier)
            new_obj.heating_schedule = heats[sch_int]
            new_obj.cooling_schedule = cools[sch_int]
            if self.humidifying_schedule is not None:
                new_obj.humidifying_schedule = humids[sch_int]
                new_obj.dehumidifying_schedule = dehumids[sch_int]
            new_objects.append(new_obj)
        return new_objects
Exemplo n.º 7
0
    def diversify(self,
                  count,
                  occupancy_stdev=20,
                  schedule_offset=1,
                  timestep=1,
                  schedule_indices=None):
        """Get an array of diversified People derived from this "average" one.

        Approximately 2/3 of the schedules in the output objects will be offset
        from the mean by the input schedule_offset (1/3 ahead and another 1/3 behind).

        Args:
            count: An positive integer for the number of diversified objects to
                generate from this mean object.
            occupancy_stdev: A number between 0 and 100 for the percent of the
                occupancy people_per_area representing one standard deviation
                of diversification from the mean. (Default 20 percent).
            schedule_offset: A positive integer for the number of timesteps at which
                the occupancy schedule of the resulting objects will be shifted - roughly
                1/3 of the objects ahead and another 1/3 behind. (Default: 1).
            timestep: An integer for the number of timesteps per hour at which the
                shifting is occurring. This must be a value between 1 and 60, which
                is evenly divisible by 60. 1 indicates that each step is an hour
                while 60 indicates that each step is a minute. (Default: 1).
            schedule_indices: An optional list of integers from 0 to 2 with a length
                equal to the input count, which will be used to set whether a given
                schedule is behind (0), ahead (2), or the same (1). This can be
                used to coordinate schedules across diversified programs. If None
                a random list of integers will be genrated. (Default: None).
        """
        # generate shifted schedules and a gaussian distribution of people_per_area
        occ_schs = self._shift_schedule(self.occupancy_schedule,
                                        schedule_offset, timestep)
        stdev = self.people_per_area * (occupancy_stdev / 100)
        new_loads, sch_ints = self._gaussian_values(count,
                                                    self.people_per_area,
                                                    stdev)
        sch_ints = sch_ints if schedule_indices is None else schedule_indices

        # generate the new objects and return them
        new_objects = []
        for load_val, sch_int in zip(new_loads, sch_ints):
            new_obj = self.duplicate()
            new_obj.identifier = clean_and_id_ep_string(self.identifier)
            new_obj.people_per_area = load_val
            new_obj.occupancy_schedule = occ_schs[sch_int]
            new_objects.append(new_obj)
        return new_objects
Exemplo n.º 8
0
def create_HB_material_no_mass(_material_name, _material_r_value):
    """ Creates an HB Style "No-Mass" Material """

    try:
        # set the default material properties
        name = _material_name
        r_value = _material_r_value
        roughness = 'MediumRough'
        therm_absp = 0.9
        sol_absp = 0.7
        vis_absp = 0.7

        # create the NoMass material
        mat = EnergyMaterialNoMass(clean_and_id_ep_string(name), r_value,
                                   roughness, therm_absp, sol_absp, vis_absp)
        mat.display_name = name

        return mat
    except Exception as e:
        print('Error creating HB Material', e)
        return None
Exemplo n.º 9
0
def create_EP_window_mat(_win_obj):
    """ Creates an E+ style material for the window based on the PHPP U-W-Installed

    Args:
        _win_obj (): The PHPP-Style window object
    Returns:
        mat: The window E+ Material
    
    """

    # Material properties
    name = 'PHPP_MAT_{}'.format(_win_obj.name)
    u_factor = _win_obj.u_w_installed
    shgc = _win_obj.glazing.gValue
    t_vis = 0.6

    # Create the material
    mat = EnergyWindowMaterialSimpleGlazSys(
        clean_and_id_ep_string(name), u_factor, shgc, t_vis)
    mat.display_name = name

    return mat
Exemplo n.º 10
0
    raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))

try:
    from honeybee_energy.load.people import People
    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:
    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):
    # make a default People name if none is provided
    if _name_ is None:
        name = "People_{}".format(uuid.uuid4())
    else:
        name = clean_and_id_ep_string(_name_)

    # get the schedules
    if isinstance(_occupancy_sch, str):
        _occupancy_sch = schedule_by_identifier(_occupancy_sch)
    if isinstance(_activity_sch_, str):
        _activity_sch_ = schedule_by_identifier(_activity_sch_)

    # create the People object
    people = People(name, _ppl_per_area, _occupancy_sch, _activity_sch_)
    if _name_ is not None:
        people.display_name = _name_
except ImportError as e:
    raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))

try:
    from honeybee_energy.load.ventilation import Ventilation
    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:
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

# make a default Ventilation name if none is provided
name = clean_and_id_ep_string('Ventilation') if _name_ is None else \
    clean_ep_string(_name_)

# get the schedule
if isinstance(_schedule_, str):
    _schedule_ = schedule_by_identifier(_schedule_)

# get default _flow_per_person_, _flow_per_area_, and _ach_
_flow_per_person_ = _flow_per_person_ if _flow_per_person_ is not None else 0.0
_flow_per_area_ = _flow_per_area_ if _flow_per_area_ is not None else 0.0
_flow_per_zone_ = _flow_per_zone_ if _flow_per_zone_ is not None else 0.0
_ach_ = _ach_ if _ach_ is not None else 0.0

# create the Ventilation object
vent = Ventilation(name, _flow_per_person_, _flow_per_area_, _flow_per_zone_,
                   _ach_, _schedule_)
try:
    from honeybee_energy.load.lighting import Lighting
    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:
    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):
    # make a default Lighting name if none is provided
    name = clean_and_id_ep_string('Lighting') if _name_ is None else \
        clean_ep_string(_name_)

    # get the schedule
    if isinstance(_schedule, str):
        _schedule = schedule_by_identifier(_schedule)

    # get default radiant, visible, and return fractions
    return_fract_ = return_fract_ if return_fract_ is not None else 0.0
    _radiant_fract_ = _radiant_fract_ if _radiant_fract_ is not None else 0.32
    _visible_fract_ = _visible_fract_ if _visible_fract_ is not None else 0.25

    # create the Lighting object
    lighting = Lighting(name, _watts_per_area, _schedule,
                        return_fract_, _radiant_fract_, _visible_fract_)
    if _name_ is not None:
Exemplo n.º 13
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)
    from honeybee_energy.lib.scheduletypelimits import schedule_type_limit_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):
    # set the defaults
    _timestep_ = 1 if _timestep_ is None else _timestep_
    start_date = Date(1, 1) if analysis_period_ is None else \
        analysis_period_.st_time.date

    # get the ScheduleTypeLimit object
    if _type_limit_ is None:
        _type_limit_ = schedule_type_limit_by_identifier('Fractional')
    elif isinstance(_type_limit_, str):
        _type_limit_ = schedule_type_limit_by_identifier(_type_limit_)

    # create the schedule object
    schedule = ScheduleFixedInterval(clean_and_id_ep_string(_name),
                                     _values,
                                     _type_limit_,
                                     _timestep_,
                                     start_date,
                                     placeholder_value=0,
                                     interpolate=False)
    schedule.display_name = _name
ghenv.Component.SubCategory = "1 :: Constructions"
ghenv.Component.AdditionalHelpFromDocStrings = "5"

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.material.opaque import EnergyMaterial
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):
    # set the default material properties
    _roughness_ = 'MediumRough' if _roughness_ is None else _roughness_
    _therm_absp_ = 0.9 if _therm_absp_ is None else _therm_absp_
    _sol_absp_ = 0.7 if _sol_absp_ is None else _sol_absp_

    # create the material
    mat = EnergyMaterial(
        clean_and_id_ep_string(_name), _thickness, _conductivity, _density,
        _spec_heat, _roughness_, _therm_absp_, _sol_absp_, _vis_absp_)
    mat.display_name = _name
    from honeybee_energy.material.shade import EnergyWindowMaterialShade
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):
    # set the default material properties
    _transmittance_ = 0.4 if _transmittance_ is None else _transmittance_
    _reflectance_ = 0.5 if _reflectance_ is None else _reflectance_
    _t_infrared_ = 0 if _t_infrared_ is None else _t_infrared_
    _emissivity_ = 0.9 if _emissivity_ is None else _emissivity_
    _conductivity_ = 0.9 if _conductivity_ is None else _conductivity_
    _dist_to_glass_ = 0.05 if _dist_to_glass_ is None else _dist_to_glass_
    _open_mult_ = 0.5 if _open_mult_ is None else _open_mult_
    _permeability_ = 0.0 if _permeability_ is None else _permeability_
    name = clean_and_id_ep_string('ShadeMaterial') if _name_ is None else \
        clean_ep_string(_name_)

    # create the material
    mat = EnergyWindowMaterialShade(name, _thickness, _transmittance_,
                                    _reflectance_, _transmittance_,
                                    _reflectance_, _t_infrared_, _emissivity_,
                                    _conductivity_, _dist_to_glass_,
                                    _open_mult_, _permeability_)
    if _name_ is not None:
        mat.display_name = _name_
    raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))

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.'
Exemplo n.º 18
0
try:  # import the honeybee-energy dependencies
    from honeybee_energy.material.shade import EnergyWindowMaterialShade
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):
    # set the default material properties
    _thickness_ = 0.005 if _thickness_ is None else _thickness_
    _transmittance_ = 0.4 if _transmittance_ is None else _transmittance_
    _reflectance_ = 0.5 if _reflectance_ is None else _reflectance_
    _t_infrared_ = 0 if _t_infrared_ is None else _t_infrared_
    _emissivity_ = 0.9 if _emissivity_ is None else _emissivity_
    _conductivity_ = 0.9 if _conductivity_ is None else _conductivity_
    _dist_to_glass_ = 0.05 if _dist_to_glass_ is None else _dist_to_glass_
    _open_mult_ = 0.5 if _open_mult_ is None else _open_mult_
    _permeability_ = 0.0 if _permeability_ is None else _permeability_

    # create the material
    mat = EnergyWindowMaterialShade(clean_and_id_ep_string(_name), _thickness_,
                                    _transmittance_, _reflectance_,
                                    _transmittance_, _reflectance_,
                                    _t_infrared_, _emissivity_, _conductivity_,
                                    _dist_to_glass_, _open_mult_,
                                    _permeability_)
    mat.display_name = _name
Exemplo n.º 19
0
    from honeybee.typing import clean_and_id_ep_string, clean_ep_string
except ImportError as e:
    raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))

try:
    from honeybee_energy.load.infiltration import Infiltration
    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:
    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):
    # make a default Infiltration name if none is provided
    name = clean_and_id_ep_string('Infiltration') if _name_ is None else \
        clean_ep_string(_name_)

    # get the schedule
    _schedule_ = _schedule_ if _schedule_ is not None else 'Always On'
    if isinstance(_schedule_, str):
        _schedule_ = schedule_by_identifier(_schedule_)

    # create the Infiltration object
    infil = Infiltration(name, _flow_per_ext_area, _schedule_)
    if _name_ is not None:
        infil.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))

if all_required_inputs(ghenv.Component):
    # get the ScheduleTypeLimit object
    if _type_limit_ is None:
        _type_limit_ = schedule_type_limit_by_identifier('Fractional')
    elif isinstance(_type_limit_, str):
        _type_limit_ = schedule_type_limit_by_identifier(_type_limit_)

    # create the schedule object
    name = clean_and_id_ep_string('ConstantSchedule') if _name_ is None else \
        clean_ep_string(_name_)
    if len(_values) == 1:
        schedule = ScheduleRuleset.from_constant_value(name, _values[0],
                                                       _type_limit_)
        idf_text, constant_none = schedule.to_idf()
    else:
        schedule = ScheduleRuleset.from_daily_values(
            name, _values, timestep=1, schedule_type_limit=_type_limit_)
        idf_year, idf_week = schedule.to_idf()
        idf_days = [
            day_sch.to_idf(_type_limit_) for day_sch in schedule.day_schedules
        ]
        idf_text = [idf_year] + idf_week + idf_days if idf_week is not None \
            else idf_year
    if _name_ is not None:
    from honeybee_energy.schedule.fixedinterval import ScheduleFixedInterval
    from honeybee_energy.lib.scheduletypelimits import schedule_type_limit_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):
    # set the defaults
    _timestep_ = 1 if _timestep_ is None else _timestep_
    start_date = Date(1, 1) if analysis_period_ is None else \
        analysis_period_.st_time.date
    name = clean_and_id_ep_string('FixedIntervalSchedule') if _name_ is None else \
        clean_ep_string(_name_)

    # get the ScheduleTypeLimit object
    if _type_limit_ is None:
        _type_limit_ = schedule_type_limit_by_identifier('Fractional')
    elif isinstance(_type_limit_, str):
        _type_limit_ = schedule_type_limit_by_identifier(_type_limit_)

    # create the schedule object
    schedule = ScheduleFixedInterval(name,
                                     _values,
                                     _type_limit_,
                                     _timestep_,
                                     start_date,
                                     placeholder_value=0,
Exemplo n.º 22
0
ghenv.Component.SubCategory = "1 :: Constructions"
ghenv.Component.AdditionalHelpFromDocStrings = "4"

try:  # import the core honeybee dependencies
    from honeybee.typing import clean_and_id_ep_string, clean_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.shade import ShadeConstruction
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):
    # set default values
    _sol_ref_ = 0.2 if _sol_ref_ is None else _sol_ref_
    _vis_ref_ = 0.2 if _vis_ref_ is None else _vis_ref_
    specular_ = False if specular_ is None else specular_
    name = clean_and_id_ep_string('ShadeConstruction') if _name_ is None else \
        clean_ep_string(_name_)

    # create the construction
    constr = ShadeConstruction(name, _sol_ref_, _vis_ref_, specular_)
    if _name_ is not None:
        constr.display_name = _name_
try:  # import the core honeybee dependencies
    from honeybee.typing import clean_and_id_ep_string, clean_ep_string
except ImportError as e:
    raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))

try:
    from honeybee_energy.programtype import ProgramType
    from honeybee_energy.lib.programtypes import program_type_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):
    # set default ratios to None
    _ratios_ = _ratios_ if len(_ratios_) != 0 else None
    name = clean_and_id_ep_string('ProgramType') if _name_ is None else \
        clean_ep_string(_name_)

    # get programs from library if a name is input
    for i, prog in enumerate(_programs):
        if isinstance(prog, str):
            _programs[i] = program_type_by_identifier(prog)

    # create blended program
    program = ProgramType.average(name, _programs, _ratios_)
    if _name_ is not None:
        program.display_name = _name_
Exemplo n.º 24
0
try:
    from honeybee_energy.programtype import ProgramType
    from honeybee_energy.lib.programtypes import program_type_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):
    # get the base program type
    if base_program_ is None:
        program = ProgramType(clean_and_id_ep_string(_name))
        program.display_name = _name
    else:
        if isinstance(base_program_, str):
            base_program_ = program_type_by_identifier(base_program_)
        program = base_program_.duplicate()
        program.identifier = clean_and_id_ep_string(_name)
        program.display_name = _name
    
    # go through each input load and assign it to the set
    if _people_ is not None:
        program.people = _people_
    if _lighting_ is not None:
        program.lighting = _lighting_
    if _electric_equip_ is not None:
        program.electric_equipment = _electric_equip_
except ImportError as e:
    raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))

try:  # import the honeybee-energy dependencies
    from honeybee_energy.material.opaque import EnergyMaterialVegetation
except ImportError as e:
    raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e))

# set the default material properties
_plant_height_ = 0.2 if _plant_height_ is None else _plant_height_
_leaf_area_ind_ = 1.0 if _leaf_area_ind_ is None else _leaf_area_ind_
_leaf_reflect_ = 0.22 if _leaf_reflect_ is None else _leaf_reflect_
_leaf_emiss_ = 0.95 if _leaf_emiss_ is None else _leaf_emiss_
soil_abs = 0.7 if _soil_reflect_ is None else 1 - _soil_reflect_
_soil_emiss_ = 0.9 if _soil_emiss_ is None else _soil_emiss_
_stomat_resist_ = 180 if _stomat_resist_ is None else _stomat_resist_
_thickness_ = 0.1 if _thickness_ is None else _thickness_
_conductivity_ = 0.35 if _conductivity_ is None else _conductivity_
_density_ = 1100 if _density_ is None else _density_
_spec_heat_ = 1200 if _spec_heat_ is None else _spec_heat_
name = clean_and_id_ep_string('VegetationMaterial') if _name_ is None else \
    clean_ep_string(_name_)

# create the material
mat = EnergyMaterialVegetation(name, _thickness_, _conductivity_, _density_,
                               _spec_heat_, 'MediumRough', _soil_emiss_,
                               soil_abs, None, _plant_height_, _leaf_area_ind_,
                               _leaf_reflect_, _leaf_emiss_, _stomat_resist_)
if _name_ is not None:
    mat.display_name = _name_
Exemplo n.º 26
0
    def diversify(self,
                  program_count,
                  occupancy_stdev=20,
                  lighting_stdev=20,
                  electric_equip_stdev=20,
                  gas_equip_stdev=20,
                  hot_water_stdev=20,
                  infiltration_stdev=20,
                  schedule_offset=1,
                  timestep=1):
        """Get an array of diversified ProgramTypes derived from this "average" one.

        This method is useful when attempting to account for the fact that not
        all rooms within a building will be used by occupants according to a
        strict regimen. Some rooms will be used more than expected and others less.

        This method uses a random number generator and gaussian distribution to
        generate loads that vary about the mean program. Note that the randomly
        generated values can be set to something predictable by using the native
        Python random.seed() method before running this method.
        
        In addition to diversifying load values, approximately 2/3 of the schedules
        in the output programs will be offset from the mean by the input
        schedule_offset (1/3 ahead and another 1/3 behind).

        Args:
            program_count: An positive integer for the number of diversified programs
                to generate from this mean program.
            occupancy_stdev: A number between 0 and 100 for the percent of the
                occupancy people_per_area representing one standard deviation
                of diversification from the mean. (Default 20 percent).
            lighting_stdev: A number between 0 and 100 for the percent of the
                lighting watts_per_area representing one standard deviation
                of diversification from the mean. (Default 20 percent).
            electric_equip_stdev: A number between 0 and 100 for the percent of the
                electric equipment watts_per_area representing one standard deviation
                of diversification from the mean. (Default 20 percent).
            gas_equip_stdev: A number between 0 and 100 for the percent of the
                gas equipment watts_per_area representing one standard deviation
                of diversification from the mean. (Default 20 percent).
            hot_water_stdev: A number between 0 and 100 for the percent of the
                service hot water flow_per_area representing one standard deviation
                of diversification from the mean. (Default 20 percent).
            infiltration_stdev: A number between 0 and 100 for the percent of the
                infiltration flow_per_exterior_area representing one standard deviation
                of diversification from the mean. (Default 20 percent).
            schedule_offset: A positive integer for the number of timesteps at which all
                schedules of the resulting programs will be shifted - roughly 1/3 of
                the programs ahead and another 1/3 behind. (Default: 1).
            timestep: An integer for the number of timesteps per hour at which the
                shifting is occurring. This must be a value between 1 and 60, which
                is evenly divisible by 60. 1 indicates that each step is an hour
                while 60 indicates that each step is a minute. (Default: 1).
        """
        # duplicate the input programs so that they can be diversified
        div_programs = [self.duplicate() for i in range(program_count)]
        for program in div_programs:
            program.identifier = clean_and_id_ep_string(self.identifier)
        sch_int = [random.randint(0, 2) for i in range(program_count)]

        # go through each load and generate diversified versions for the div_programs
        if self.people is not None and occupancy_stdev != 0:
            div_people = self.people.diversify(program_count, occupancy_stdev,
                                               schedule_offset, timestep,
                                               sch_int)
            for i, ppl in enumerate(div_people):
                div_programs[i].people = ppl
        if self.lighting is not None and lighting_stdev != 0:
            div_lighting = self.lighting.diversify(program_count,
                                                   lighting_stdev,
                                                   schedule_offset, timestep,
                                                   sch_int)
            for i, light in enumerate(div_lighting):
                div_programs[i].lighting = light
        if self.electric_equipment is not None and electric_equip_stdev != 0:
            div_e_equipment = self.electric_equipment.diversify(
                program_count, electric_equip_stdev, schedule_offset, timestep,
                sch_int)
            for i, e_equip in enumerate(div_e_equipment):
                div_programs[i].electric_equipment = e_equip
        if self.gas_equipment is not None and gas_equip_stdev != 0:
            div_g_equipment = self.gas_equipment.diversify(
                program_count, gas_equip_stdev, schedule_offset, timestep,
                sch_int)
            for i, g_equip in enumerate(div_g_equipment):
                div_programs[i].gas_equipment = g_equip
        if self.service_hot_water is not None and hot_water_stdev != 0:
            div_hot_water = self.service_hot_water.diversify(
                program_count, hot_water_stdev, schedule_offset, timestep,
                sch_int)
            for i, shw in enumerate(div_hot_water):
                div_programs[i].service_hot_water = shw
        if self.infiltration is not None and infiltration_stdev != 0:
            div_infiltration = self.infiltration.diversify(
                program_count, infiltration_stdev, schedule_offset, timestep,
                sch_int)
            for i, inf in enumerate(div_infiltration):
                div_programs[i].infiltration = inf
        if self.setpoint is not None and schedule_offset != 0:
            div_setpoint = self.setpoint.diversify(program_count,
                                                   schedule_offset, timestep,
                                                   sch_int)
            for i, setpt in enumerate(div_setpoint):
                div_programs[i].setpoint = setpt
        return div_programs
Exemplo n.º 27
0
            rooms.append(hb_obj.duplicate())
        else:
            raise ValueError('Expected Honeybee Room or Model. Got {}.'.format(
                type(hb_obj)))

    # create the instance of the HVAC system to be applied to the rooms
    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
    # set default values for heat recovery
    sens = sensible_hr_ if sensible_hr_ is not None else autosize
    latent = latent_hr_ if latent_hr_ is not None else autosize
    # get an identifier for the HVAC system
    name = clean_and_id_ep_string(_name_) if _name_ is not None else str(
        uuid.uuid4())[:8]
    hvac = hvac_class(name, vintage, _sys_name, sens, latent)
    if _name_ is not None:
        hvac.display_name = _name_

    # apply the HVAC system to the rooms
    for room in rooms:
        if room.properties.energy.is_conditioned:
            room.properties.energy.hvac = hvac
Exemplo n.º 28
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
Exemplo n.º 29
0
try:  # import the core honeybee dependencies
    from honeybee.typing import clean_and_id_ep_string, clean_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.window import WindowConstruction
    from honeybee_energy.lib.materials import window_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):
    name = clean_and_id_ep_string('WindowConstruction') if _name_ is None else \
        clean_ep_string(_name_)

    material_objs = []
    for material in _materials:
        if isinstance(material, str):
            material = window_material_by_identifier(material)
        material_objs.append(material)

    constr = WindowConstruction(name, material_objs)
    if _name_ is not None:
        constr.display_name = _name_
Exemplo n.º 30
0
        else:
            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: