Пример #1
0
    def from_idf(cls, design_days=None, sizing_parameter=None, location=None):
        """Create a SizingParameter object from an EnergyPlus IDF text string.

        Args:
            design_days: An array of of IDF SizingPeriod:DesignDay strings that
                represent the criteria for which the HVAC systems will be sized.
                If None, no sizing criteria will be included. Default: None.
            sizing_parameter: A text string for an EnergyPlus Sizing:Parameters
                definition. If None, defaults of 1.25 anf 1.15 will be used.
                Default: None.
            location: An optional Ladybug Location object, which gets assigned
                to the DesignDay objects in order to interpret their SkyConditions.
                This object is not used in the export to IDF. If None, the
                intersection of the equator with the prime meridian will be used.
                Default: None.
        """
        # process the input design_days
        des_day_objs = None
        if design_days is not None:
            location = Location() if location is None else location
            des_day_objs = [DesignDay.from_idf(dday, location) for dday in design_days]

        # process the sizing_parameter
        heating_factor = 1.25
        cooling_factor = 1.15
        if sizing_parameter is not None:
            try:
                ep_strs = parse_idf_string(sizing_parameter, 'Sizing:Parameters,')
                heating_factor = ep_strs[0] if ep_strs[0] != '' else 1.25
                cooling_factor = ep_strs[1] if ep_strs[1] != '' else 1.15
            except IndexError:
                pass  # shorter SizingParameters definition

        return cls(des_day_objs, heating_factor, cooling_factor)
Пример #2
0
def test_design_day_hourly_data():
    """Test hourly data properties of a standard ddy."""
    location = Location('Test City', '-', 'USA', 34.20, -118.35, -8, 226)
    date = Date(8, 21)
    des_day = DesignDay.from_design_day_properties('Test Day',
                                                   'SummerDesignDay', location,
                                                   date, 36.8, 13.2, 'Wetbulb',
                                                   20.5, 98639, 3.9, 170,
                                                   'ASHRAETau', [0.436, 2.106])
    # dry bulb values
    db_data_collect = des_day.hourly_dry_bulb
    assert db_data_collect[5] == approx(23.6, rel=1e-1)
    assert db_data_collect[14] == approx(36.8, rel=1e-1)

    # dew point values
    dpt_data_collect = des_day.hourly_dew_point
    assert dpt_data_collect[0] == approx(11.296, rel=1e-1)
    assert dpt_data_collect[-1] == approx(11.296, rel=1e-1)

    # relative humidity values
    rh_data_collect = des_day.hourly_relative_humidity
    assert rh_data_collect[5] == approx(45.896, rel=1e-1)
    assert rh_data_collect[14] == approx(21.508, rel=1e-1)

    # barometric pressure values
    bp_data_collect = des_day.hourly_barometric_pressure
    assert bp_data_collect[0] == approx(98639, rel=1e-1)
    assert bp_data_collect[-1] == approx(98639, rel=1e-1)

    # wind speed values
    ws_data_collect = des_day.hourly_wind_speed
    assert -0.1 < ws_data_collect[0] - 3.9 < 0.1
    assert -0.1 < ws_data_collect[-1] - 3.9 < 0.1

    # wind direction values
    wd_data_collect = des_day.hourly_wind_direction
    assert wd_data_collect[0] == approx(170, rel=1e-1)
    assert wd_data_collect[-1] == approx(170, rel=1e-1)

    # radiation values
    direct_normal_rad, diffuse_horizontal_rad, global_horizontal_rad = \
        des_day.hourly_solar_radiation
    assert direct_normal_rad[0] == 0
    assert direct_normal_rad[11] == approx(891.46, rel=1e-1)
    assert diffuse_horizontal_rad[0] == 0
    assert diffuse_horizontal_rad[11] == approx(165.32, rel=1e-1)
    assert global_horizontal_rad[0] == 0
    assert global_horizontal_rad[11] == approx(985.05, rel=1e-1)

    # sky cover values
    sc_data_collect = des_day.hourly_sky_cover

    # sky cover values
    hi_data_collect = des_day.hourly_horizontal_infrared
Пример #3
0
 def test_design_day_from_properties(self):
     """Test hourly data properties of a standard ddy."""
     location = Location('Test City', 'USA', 34.20, -118.35, -8, 226)
     a_period = AnalysisPeriod(12, 21, 0, 12, 21, 23)
     des_day = DesignDay.from_design_day_properties(
         'Test Day', 'WinterDesignDay', location, a_period, 3.9, 0,
         'Wetbulb', 3.9, 98639, 0.8, 330, 'ASHRAEClearSky', [0])
     assert des_day.location == location
     new_period = des_day.analysis_period
     assert new_period.st_month == a_period.st_month
     assert new_period.st_day == a_period.st_day
     assert new_period.st_hour == a_period.st_hour
     assert new_period.end_month == a_period.end_month
     assert new_period.end_day == a_period.end_day
     assert new_period.end_hour == a_period.end_hour
Пример #4
0
    def from_dict(cls, data):
        """Create a SizingParameter object from a dictionary.

        Args:
            data: A SizingParameter dictionary in following the format.

        .. code-block:: python

            {
            "type": "SizingParameter",
            "design_days": [],  # Array of Ladybug DesignDay dictionaries
            "heating_factor": 1.25,
            "cooling_factor": 1.15
            }
        """
        assert data['type'] == 'SizingParameter', \
            'Expected SizingParameter dictionary. Got {}.'.format(data['type'])
        design_days = None
        if 'design_days' in data and data['design_days'] is not None:
            design_days = [DesignDay.from_dict(dday) for dday in data['design_days']]
        heating_factor = data['heating_factor'] if 'heating_factor' in data else 1.25
        cooling_factor = data['cooling_factor'] if 'cooling_factor' in data else 1.15
        return cls(design_days, heating_factor, cooling_factor)
Пример #5
0
ghenv.Component.SubCategory = '4 :: AlternativeWeather'
ghenv.Component.AdditionalHelpFromDocStrings = '3'

try:
    from ladybug.designday import DesignDay
    from ladybug.dt import Date, DateTime
except ImportError as e:
    raise ImportError('\nFailed to import ladybug:\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 defaults for relevant items
    if _dry_bulb_range_ is None:
        _dry_bulb_range_ = 0
    if _barometric_p_ is None:
        _barometric_p_ = 101325

    # process the input date
    try:
        date = Date.from_date_string(_date)
    except ValueError:
        date = DateTime.from_date_time_string(_date).date

    design_day = DesignDay.from_design_day_properties(
        _name, _day_type, _location, date, _dry_bulb_max, _dry_bulb_range_,
        _humidity_type, _humidity_value, _barometric_p_, _wind_speed,
        _wind_dir, _sky_type, _sky_properties)