Exemple #1
0
    def __init__(self,
                 name,
                 lower_limit=None,
                 upper_limit=None,
                 numeric_type='Continuous',
                 unit_type='Dimensionless'):
        """Initialize ScheduleTypeLimit.

        Args:
            name: Text string for schedule type name. Must be <= 100 characters.
                Can include spaces but special characters will be stripped out.
            lower_limit: An optional number for the lower limit for values in the
                schedule. If None, there will be no lower limit.
            upper_limit: An optional number for the upper limit for values in the
                schedule. If None, there will be no upper limit.
            numeric_type: Either one of two strings: 'Continuous' or 'Discrete'.
                The latter means that only integers are accepted as schedule values.
                Default: 'Continuous'.
            unit_type: Text for an EnergyPlus unit type, which will be used
                to assign units to the values in the schedule.  Note that this field
                is not used in the actual calculations of EnergyPlus.
                Default: 'Dimensionless'. Choose from the following options:
                'Dimensionless', 'Temperature', 'DeltaTemperature', 'PrecipitationRate',
                'Angle', 'ConvectionCoefficient', 'ActivityLevel', 'Velocity',
                'Capacity', 'Power', 'Availability', 'Percent', 'Control', 'Mode'
        """
        # process the name and limits
        self._name = valid_ep_string(name, 'schedule type name')
        self._lower_limit = float_in_range(lower_limit) if lower_limit is not \
            None else None
        self._upper_limit = float_in_range(upper_limit) if upper_limit is not \
            None else None
        if self._lower_limit is not None and self._upper_limit is not None:
            assert self._lower_limit <= self._upper_limit, 'ScheduleTypeLimit ' \
                'lower_limit must be less than upper_limit. {} > {}.'.format(
                    self._lower_limit, self._upper_limit)

        # process the numeric type
        self._numeric_type = numeric_type.capitalize() or 'Continuous'
        assert self._numeric_type in self.NUMERIC_TYPES, '"{}" is not an acceptable ' \
            'numeric type.  Choose from the following:\n{}'.format(
                numeric_type, self.NUMERIC_TYPES)

        # process the unit type and assign the ladybug data type and unit
        if unit_type is None:
            self._data_type, self._unit = self._default_lb_unit_type[
                'Dimensionless']
            self._unit_type = 'Dimensionless'
        else:
            clean_input = valid_string(unit_type).lower()
            for key in self.UNIT_TYPES:
                if key.lower() == clean_input:
                    unit_type = key
                    break
            else:
                raise ValueError(
                    'unit_type {} is not recognized.\nChoose from the '
                    'following:\n{}'.format(unit_type, self.UNIT_TYPES))
            self._data_type, self._unit = self._default_lb_unit_type[unit_type]
            self._unit_type = unit_type
Exemple #2
0
 def radiant_fraction(self, value):
     if value is not None:
         self._radiant_fraction = float_in_range(
             value, 0.0, 1.0, 'lighting radiant fraction')
     else:
         self._radiant_fraction = 0.32
     self._check_fractions()
Exemple #3
0
 def latent_heat_recovery(self, value):
     if value is None or value == 0:
         self._latent_heat_recovery = 0
     else:
         self._air_loop_check('latent_heat_recovery')
         self._latent_heat_recovery = \
             float_in_range(value, 0.0, 1.0, 'hvac latent heat recovery')
Exemple #4
0
 def sensible_heat_recovery(self, value):
     if value is None or value == 0:
         self._sensible_heat_recovery = 0
     else:
         self._air_loop_check('sensible_heat_recovery')
         self._sensible_heat_recovery = \
             float_in_range(value, 0.0, 1.0, 'hvac sensible heat recovery')
Exemple #5
0
 def return_air_fraction(self, value):
     if value is not None:
         self._return_air_fraction = float_in_range(
             value, 0.0, 1.0, 'lighting return air fraction')
     else:
         self._return_air_fraction = 0
     self._check_fractions()
Exemple #6
0
 def solar_reflectance(self, s_ref):
     s_ref = float_in_range(s_ref, 0.0, 1.0,
                            'glazing material solar reflectance')
     assert s_ref + self._solar_transmittance <= 1, 'Sum of window transmittance ' \
         'and reflectance ({}) is greater than 1.'.format(
             s_ref + self._solar_transmittance)
     self._solar_reflectance = s_ref
Exemple #7
0
 def visible_reflectance(self, v_ref):
     v_ref = float_in_range(v_ref, 0.0, 1.0,
                            'glazing material visible reflectance')
     assert v_ref + self._visible_transmittance <= 1, 'Sum of window transmittance ' \
         'and reflectance ({}) is greater than 1.'.format(
             v_ref + self._visible_transmittance)
     self._visible_reflectance = v_ref
Exemple #8
0
 def solar_reflectance_back(self, s_ref):
     if s_ref is not None:
         s_ref = float_in_range(s_ref, 0.0, 1.0, 'glazing material solar reflectance')
         assert s_ref + self._solar_transmittance <= 1, 'Sum of window ' \
             'transmittance and reflectance ({}) is greater than 1.'.format(
                 s_ref + self._solar_transmittance)
     self._solar_reflectance_back = s_ref
Exemple #9
0
 def visible_fraction(self, value):
     if value is not None:
         self._visible_fraction = float_in_range(
             value, 0.0, 1.0, 'lighting visible fraction')
     else:
         self._visible_fraction = 0.25
     self._check_fractions()
Exemple #10
0
 def latent_heat_recovery(self, value):
     if value == autosize or value is None:
         self._latent_heat_recovery = autosize
     else:
         assert self._has_air_loop, \
             'HVAC system must have an air loop to set latent_heat_recovery.'
         self._latent_heat_recovery = \
             float_in_range(value, 0.0, 1.0, 'hvac latent heat recovery')
Exemple #11
0
 def visible_reflectance_back(self, v_ref):
     if v_ref is not None:
         v_ref = float_in_range(v_ref, 0.0, 1.0,
                                'glazing material visible reflectance')
         assert v_ref + self._visible_transmittance <= 1, 'Sum of window ' \
             'transmittance and reflectance ({}) is greater than 1.'.format(
                 v_ref + self._visible_transmittance)
     self._visible_reflectance_back = v_ref
 def _check_schedule(self, schedule):
     if len(schedule) == 24:
         return tuple(
             float_in_range(x, 0, 1, 'schedule value') for x in schedule)
     else:
         raise ValueError(
             'Traffic schedules must be lists of 24 values. Current schedule '
             'has length ({})'.format(len(schedule)))
Exemple #13
0
 def dehumidifying_setpoint(self, value):
     if value is not None:
         value = float_in_range(value, 0, 100, 'dehumidifying setpoint')
         schedule = ScheduleRuleset.from_constant_value(
             '{}_DeHumidSetp'.format(self.name), value, _type_lib.humidity)
         self.dehumidifying_schedule = schedule
     else:
         self.dehumidifying_schedule = None
Exemple #14
0
 def solar_transmittance(self, s_tr):
     s_tr = float_in_range(s_tr, 0.0, 1.0, 'glazing material solar transmittance')
     assert s_tr + self._solar_reflectance <= 1, 'Sum of window transmittance and ' \
         'reflectance ({}) is greater than 1.'.format(s_tr + self._solar_reflectance)
     if self._solar_reflectance_back is not None:
         assert s_tr + self._solar_reflectance_back <= 1, 'Sum of window ' \
             'transmittance and reflectance ({}) is greater than 1.'.format(
                 s_tr + self._solar_reflectance_back)
     self._solar_transmittance = s_tr
Exemple #15
0
 def visible_transmittance(self, v_tr):
     v_tr = float_in_range(v_tr, 0.0, 1.0, 'glazing material visible transmittance')
     assert v_tr + self._visible_reflectance <= 1, 'Sum of window transmittance ' \
         'and reflectance ({}) is greater than 1.'.format(
             v_tr + self._visible_reflectance)
     if self._visible_reflectance_back is not None:
         assert v_tr + self._visible_reflectance_back <= 1, 'Sum of window ' \
             'transmittance and reflectance ({}) is greater than 1.'.format(
                 v_tr + self._visible_reflectance_back)
     self._visible_transmittance = v_tr
Exemple #16
0
    def __init__(self,
                 identifier,
                 lower_limit=no_limit,
                 upper_limit=no_limit,
                 numeric_type='Continuous',
                 unit_type='Dimensionless'):
        """Initialize ScheduleTypeLimit."""
        # process the identifier and limits
        self._identifier = valid_ep_string(identifier,
                                           'schedule type identifier')
        self._display_name = None
        self._lower_limit = float_in_range(lower_limit) if lower_limit is not \
            None and lower_limit != no_limit else no_limit
        self._upper_limit = float_in_range(upper_limit) if upper_limit is not \
            None and upper_limit != no_limit else no_limit
        if self._lower_limit != no_limit and self._upper_limit != no_limit:
            assert self._lower_limit <= self._upper_limit, 'ScheduleTypeLimit ' \
                'lower_limit must be less than upper_limit. {} > {}.'.format(
                    self._lower_limit, self._upper_limit)

        # process the numeric type
        self._numeric_type = numeric_type.capitalize() or 'Continuous'
        assert self._numeric_type in self.NUMERIC_TYPES, '"{}" is not an acceptable ' \
            'numeric type.  Choose from the following:\n{}'.format(
                numeric_type, self.NUMERIC_TYPES)

        # process the unit type and assign the ladybug data type and unit
        if unit_type is None:
            self._data_type, self._unit = self._default_lb_unit_type[
                'Dimensionless']
            self._unit_type = 'Dimensionless'
        else:
            clean_input = valid_string(unit_type).lower()
            for key in self.UNIT_TYPES:
                if key.lower() == clean_input:
                    unit_type = key
                    break
            else:
                raise ValueError(
                    'unit_type {} is not recognized.\nChoose from the '
                    'following:\n{}'.format(unit_type, self.UNIT_TYPES))
            self._data_type, self._unit = self._default_lb_unit_type[unit_type]
            self._unit_type = unit_type
 def __init__(self,
              depth,
              offset=0,
              angle=0,
              contour_vector=Vector2D(0, 1),
              flip_start_side=False):
     """Initialize LouversBase."""
     self._depth = float_positive(depth, 'louver depth')
     self._offset = float_positive(offset, 'louver offset')
     self._angle = float_in_range(angle, -90, 90, 'overhang angle')
     assert isinstance(contour_vector, Vector2D), 'Expected Vector2D for ' \
         'LouversByDistance contour_vector. Got {}.'.format(type(contour_vector))
     self._contour_vector = contour_vector
     self._flip_start_side = bool(flip_start_side)
Exemple #18
0
def test_float_in_range():
    """Test the float_in_range method."""
    assert isinstance(float_in_range(2.0, 0, 10, 'test number'), float)
    assert isinstance(float_in_range(2, 0, 10, 'test number'), float)
    assert isinstance(float_in_range('2', 0, 10, 'test number'), float)

    with pytest.raises(AssertionError):
        assert isinstance(float_in_range(2, 0, 1, 'test number'), float)
    with pytest.raises(TypeError):
        assert isinstance(float_in_range('two', 0, 10, 'test number'), float)
    with pytest.raises(TypeError):
        assert isinstance(float_in_range([2], 0, 10, 'test number'), float)

    try:
        float_in_range(2, 0, 1, 'test number')
    except AssertionError as e:
        assert 'test number' in str(e)
Exemple #19
0
 def __init__(self,
              window_ratio,
              window_height,
              sill_height,
              horizontal_separation,
              vertical_separation=0):
     """Initialize RepeatingWindowRatio."""
     self._window_ratio = float_in_range(window_ratio, 0, 0.95,
                                         'window ratio')
     self._window_height = float_positive(window_height, 'window height')
     self._sill_height = float_positive(sill_height, 'sill height')
     self._horizontal_separation = \
         float_positive(horizontal_separation, 'window horizontal separation')
     self._vertical_separation = \
         float_positive(vertical_separation, 'window vertical separation')
Exemple #20
0
 def vt(self, vt):
     self._vt = float_in_range(vt, 0.0, 1.0,
                               'glazing material visible transmittance')
Exemple #21
0
 def shgc(self, sc):
     self._shgc = float_in_range(sc, 0.0, 1.0, 'glazing material shgc')
Exemple #22
0
 def u_factor(self, u_fac):
     # NOTE: u-values above 5.8 are not usually realistic but 12 is used as a hard limit
     self._u_factor = float_in_range(u_fac, 0.0, 12,
                                     'glazing material u-factor')
Exemple #23
0
 def dirt_correction(self, dirt):
     self._dirt_correction = float_in_range(
         dirt, 0.0, 1.0, 'glazing material dirt correction')
Exemple #24
0
 def emissivity_back(self, ir_e):
     if ir_e is not None:
         ir_e = float_in_range(ir_e, 0.0, 1.0,
                               'glazing material emissivity')
     self._emissivity_back = ir_e
Exemple #25
0
 def emissivity(self, ir_e):
     ir_e = float_in_range(ir_e, 0.0, 1.0, 'glazing material emissivity')
     self._emissivity = ir_e
Exemple #26
0
 def infrared_transmittance(self, ir_tr):
     self._infrared_transmittance = float_in_range(
         ir_tr, 0.0, 1.0, 'glazing material infrared transmittance')
 def azimuth(self, value):
     value = typing.float_in_range(value, 0, 360, 'Solar azimuth')
     self._azimuth = value
Exemple #28
0
 def radiant_fraction(self, value):
     self._radiant_fraction = float_in_range(value, 0.0, 1.0,
                                             'people radiant fraction')
Exemple #29
0
 def latent_fraction(self, value):
     if value == autocalculate:
         self._latent_fraction = autocalculate
     else:
         self._latent_fraction = float_in_range(value, 0.0, 1.0,
                                                'people latent fraction')
 def altitude(self, value):
     value = typing.float_in_range(value, -90, 90, 'Solar altitude')
     self._altitude = value