Exemple #1
0
def test_valid_ep_string():
    """Test the valid_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 valid_ep_string(correct_str) == correct_str
    assert valid_ep_string(incorrect_str) == correct_str
    with pytest.raises(AssertionError):
        valid_ep_string(long_str)
Exemple #2
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 #3
0
 def vintage(self, value):
     clean_input = valid_ep_string(value).lower()
     for key in self.VINTAGES:
         if key.lower() == clean_input:
             value = key
             break
     else:
         raise ValueError(
             'Template HVAC vintage "{}" is not recognized.\nChoose from the '
             'following:\n{}'.format(value, self.VINTAGES))
     self._vintage = value
Exemple #4
0
 def equipment_type(self, value):
     if value is not None:
         clean_input = valid_ep_string(value).lower()
         for key in self.EQUIPMENT_TYPES:
             if key.lower() == clean_input:
                 value = key
                 break
         else:
             raise ValueError(
                 'HVAC equipment_type "{}" is not supported for {}.\n'
                 'Choose from the following:\n{}'.format(
                     value, self.__class__.__name__, '\n'.join(self.EQUIPMENT_TYPES)))
         self._equipment_type = value
     else:
         self._equipment_type = self.EQUIPMENT_TYPES[0]
Exemple #5
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
Exemple #6
0
 def identifier(self, value):
     self._identifier = valid_ep_string(
         value, 'transformer properties identifier')
Exemple #7
0
 def identifier(self, identifier):
     self._identifier = valid_ep_string(identifier, 'identifier')
Exemple #8
0
 def building_identifier(self, value):
     self._building_identifier = valid_ep_string(value, 'building_identifier') \
         if value is not None else None
Exemple #9
0
 def system_identifier(self, value):
     self._system_identifier = valid_ep_string(value, 'system_identifier') \
         if value is not None else None
Exemple #10
0
 def name(self, name):
     self._name = valid_ep_string(name)
Exemple #11
0
 def identifier(self, identifier):
     self._identifier = valid_ep_string(identifier, 'construction identifier')
Exemple #12
0
 def identifier(self, identifier):
     self._identifier = valid_ep_string(
         identifier, 'schedule fixed interval identifier')
Exemple #13
0
 def name(self, name):
     self._name = valid_ep_string(name, 'construction name')
Exemple #14
0
 def name(self, name):
     self._name = valid_ep_string(name, 'material name')
Exemple #15
0
 def name(self, name):
     self._name = valid_ep_string(name, 'schedule fixed interval name')
Exemple #16
0
 def name(self, name):
     self._name = valid_ep_string(name, 'schedule day')
Exemple #17
0
 def name(self, name):
     self._name = valid_ep_string(name, 'program type name')
 def identifier(self, identifier):
     self._identifier = valid_ep_string(identifier,
                                        'program type identifier')
Exemple #19
0
 def identifier(self, identifier):
     self._identifier = valid_ep_string(identifier, 'schedule day identifier')
 def identifier(self, identifier):
     self._identifier = valid_ep_string(identifier, 'HVAC system identifier')
Exemple #21
0
 def identifier(self, value):
     self._identifier = valid_ep_string(value, 'wire identifier')