コード例 #1
0
def test_comfort_check():
    """Test comfort check on PMVParameter."""
    pmv_comf = PMVParameter()
    comf_test = pmv_comf.is_comfortable(13, 0.01)
    assert comf_test == 0
    comf_test = pmv_comf.is_comfortable(7, 0.01)
    assert comf_test == 1
コード例 #2
0
def test_discomfort_reason_check():
    """Test the thermal condition check on PMVParameter."""
    pmv_comf = PMVParameter()
    condition_test = pmv_comf.discomfort_reason(-1, 20, 0.01)
    assert condition_test == -1
    condition_test = pmv_comf.discomfort_reason(0, 5, 0.01)
    assert condition_test == 0
コード例 #3
0
def test_passive_solar_polygon():
    """Test the passive_solar_polygon method."""
    # test the polygon with the default comfort settings
    path = './tests/epw/chicago.epw'
    epw = EPW(path)
    psych_chart = PsychrometricChart(epw.dry_bulb_temperature,
                                     epw.relative_humidity)
    poly_obj = PolygonPMV(psych_chart)
    sol_vals, delta = poly_obj.evaluate_passive_solar(
        epw.global_horizontal_radiation)
    sol_poly = poly_obj.passive_solar_polygon(delta)
    sol_poly = poly_obj.passive_solar_polygon(delta)
    assert len(sol_poly) == 4
    assert 0 < sum(sol_vals) < 8760

    # test the polygon with custom comfort settings
    psych_chart = PsychrometricChart(15, 30, max_temperature=40)
    pmv_par = PMVParameter(humid_ratio_upper=0.008, humid_ratio_lower=0.005)
    poly_obj = PolygonPMV(psych_chart, comfort_parameter=pmv_par)
    sol_vals, delta = poly_obj.evaluate_passive_solar([200])
    sol_poly = poly_obj.passive_solar_polygon(delta)
    assert sol_vals == [1]

    # test the polygon with custom comfort settings
    psych_chart = PsychrometricChart(10, 30, max_temperature=40)
    pmv_par = PMVParameter(humid_ratio_upper=0.014, humid_ratio_lower=0.005)
    poly_obj = PolygonPMV(psych_chart, comfort_parameter=pmv_par)
    bal = 12.8
    sol_vals, delta = poly_obj.evaluate_passive_solar([200],
                                                      balance_temperature=bal)
    sol_poly = poly_obj.passive_solar_polygon(delta, bal)
    assert sol_vals == [1]
コード例 #4
0
def test_thermal_condition_check():
    """Test the thermal condition check on PMVParameter."""
    pmv_comf = PMVParameter()
    condition_test = pmv_comf.thermal_condition(-1, 20)
    assert condition_test == -1
    condition_test = pmv_comf.thermal_condition(0, 5)
    assert condition_test == 0
コード例 #5
0
def test_pmv_parameter_invalid():
    """Test PMVParameter for invalid inputs."""
    ppd_comfort_thresh = 110
    humid_ratio_up = 12
    humid_ratio_low = -1
    still_air_thresh = -1

    with pytest.raises(AssertionError):
        PMVParameter(ppd_comfort_thresh=ppd_comfort_thresh)
    with pytest.raises(AssertionError):
        PMVParameter(humid_ratio_upper=humid_ratio_up)
    with pytest.raises(AssertionError):
        PMVParameter(humid_ratio_lower=humid_ratio_low)
    with pytest.raises(AssertionError):
        PMVParameter(still_air_threshold=still_air_thresh)
コード例 #6
0
def test_pmv_parameter_to_from_str():
    """Test PMVParameter."""
    ppd_comfort_thresh = 20
    humid_ratio_up = 0.012
    humid_ratio_low = 0.004
    still_air_thresh = 0.2

    pmv_comf = PMVParameter(
        ppd_comfort_thresh, humid_ratio_up, humid_ratio_low, still_air_thresh)
    new_pmv_comf = PMVParameter.from_string(str(pmv_comf))

    assert new_pmv_comf.ppd_comfort_thresh == ppd_comfort_thresh
    assert new_pmv_comf.humid_ratio_upper == humid_ratio_up
    assert new_pmv_comf.humid_ratio_lower == humid_ratio_low
    assert new_pmv_comf.still_air_threshold == still_air_thresh
コード例 #7
0
def test_pmv_collection_defaults():
    """Test the default inputs assigned to the PMV collection."""
    calc_length = 24
    air_temp_header = Header(Temperature(), 'C',
                             AnalysisPeriod(end_month=1, end_day=1))
    air_temp = HourlyContinuousCollection(air_temp_header, [24] * calc_length)
    pmv_obj = PMV(air_temp, 50)

    assert isinstance(pmv_obj.rad_temperature, HourlyContinuousCollection)
    assert len(pmv_obj.rad_temperature.values) == calc_length
    assert pmv_obj.rad_temperature[0] == pmv_obj.air_temperature[0]

    assert isinstance(pmv_obj.air_speed, HourlyContinuousCollection)
    assert len(pmv_obj.air_speed.values) == calc_length
    assert pmv_obj.air_speed[0] == 0.1

    assert isinstance(pmv_obj.met_rate, HourlyContinuousCollection)
    assert len(pmv_obj.met_rate.values) == calc_length
    assert pmv_obj.met_rate[0] == 1.1

    assert isinstance(pmv_obj.clo_value, HourlyContinuousCollection)
    assert len(pmv_obj.clo_value.values) == calc_length
    assert pmv_obj.clo_value[0] == 0.7

    assert isinstance(pmv_obj.external_work, HourlyContinuousCollection)
    assert len(pmv_obj.external_work.values) == calc_length
    assert pmv_obj.external_work[0] == 0

    assert isinstance(pmv_obj.comfort_parameter, PMVParameter)
    default_par = PMVParameter()
    assert pmv_obj.comfort_parameter.ppd_comfort_thresh == default_par.ppd_comfort_thresh
    assert pmv_obj.comfort_parameter.humid_ratio_upper == default_par.humid_ratio_upper
    assert pmv_obj.comfort_parameter.humid_ratio_lower == default_par.humid_ratio_lower
    assert pmv_obj.comfort_parameter.still_air_threshold == default_par.still_air_threshold
コード例 #8
0
def test_pmv_collection_immutability():
    """Test that the PMV collection is immutable."""
    calc_length = 24
    air_temp_header = Header(Temperature(), 'C',
                             AnalysisPeriod(end_month=1, end_day=1))
    air_temp = HourlyContinuousCollection(air_temp_header, [24] * calc_length)
    pmv_obj = PMV(air_temp, 50)

    # check that editing the original collection does not mutate the object
    air_temp[0] = 26
    assert pmv_obj.air_temperature[0] == 24

    # check that editing collection properties does not mutate the object
    with pytest.raises(Exception):
        pmv_obj.air_temperature[0] = 26
    with pytest.raises(Exception):
        pmv_obj.air_temperature.values = [26] * calc_length
    with pytest.raises(Exception):
        pmv_obj.predicted_mean_vote[0] = 0.5
    with pytest.raises(Exception):
        pmv_obj.predicted_mean_vote.values = [0.5] * calc_length
    pmv_obj.comfort_parameter.ppd_comfort_thresh = 15
    assert pmv_obj.comfort_parameter.ppd_comfort_thresh == 10

    # check that properties cannot be edited directly
    with pytest.raises(Exception):
        pmv_obj.air_temperature = air_temp
    with pytest.raises(Exception):
        pmv_obj.predicted_mean_vote = air_temp
    with pytest.raises(Exception):
        pmv_obj.comfort_parameter = PMVParameter()
コード例 #9
0
def _load_pmv_par_str(comfort_par_str):
    """Load a PMVParameter from a string.

    Args:
        comfort_par_str: A string of a PMVParameter to be loaded.
    """
    if comfort_par_str is not None and comfort_par_str != '' \
            and comfort_par_str != 'None':
        return PMVParameter.from_string(comfort_par_str)
コード例 #10
0
def test_fan_use_polygon():
    """Test the fan_use_polygon method."""
    # test the polygon with the default comfort settings
    psych_chart = PsychrometricChart(20, 50)
    poly_obj = PolygonPMV(psych_chart)
    fan_poly = poly_obj.fan_use_polygon()
    val_list = poly_obj.evaluate_polygon(fan_poly)
    assert val_list == [0]

    # test the polygon with custom comfort settings
    psych_chart = PsychrometricChart(30, 30)
    pmv_par = PMVParameter(humid_ratio_upper=0.008, humid_ratio_lower=0.005)
    poly_obj = PolygonPMV(psych_chart, comfort_parameter=pmv_par)
    fan_poly = poly_obj.fan_use_polygon(1.5)
    val_list = poly_obj.evaluate_polygon(fan_poly)
    assert val_list == [1]
コード例 #11
0
def test_evaporative_cooling_polygon():
    """Test the evaporative_cooling_polygon method."""
    # test the polygon with the default comfort settings
    psych_chart = PsychrometricChart(20, 50)
    poly_obj = PolygonPMV(psych_chart)
    evap_poly = poly_obj.evaporative_cooling_polygon()
    val_list = poly_obj.evaluate_polygon(evap_poly)
    assert val_list == [0]

    # test the polygon with custom comfort settings
    psych_chart = PsychrometricChart(35, 10)
    pmv_par = PMVParameter(humid_ratio_upper=0.008, humid_ratio_lower=0.005)
    poly_obj = PolygonPMV(psych_chart, comfort_parameter=pmv_par)
    evap_poly = poly_obj.evaporative_cooling_polygon()
    val_list = poly_obj.evaluate_polygon(evap_poly)
    assert val_list == [1]
コード例 #12
0
def test_internal_heat_polygon():
    """Test the internal_heat_polygon method."""
    # test the polygon with the default comfort settings
    psych_chart = PsychrometricChart(25, 50)
    poly_obj = PolygonPMV(psych_chart)
    inht_poly = poly_obj.internal_heat_polygon()
    val_list = poly_obj.evaluate_polygon(inht_poly)
    assert val_list == [0]

    # test the polygon with custom comfort settings
    psych_chart = PsychrometricChart(15, 50)
    pmv_par = PMVParameter(humid_ratio_upper=0.008, humid_ratio_lower=0.005)
    poly_obj = PolygonPMV(psych_chart, comfort_parameter=pmv_par)
    inht_poly = poly_obj.internal_heat_polygon()
    val_list = poly_obj.evaluate_polygon(inht_poly)
    assert val_list == [1]
コード例 #13
0
def test_init_pmv_collection_full_input():
    """Test the initialization of the PMV collection will all inputs."""
    calc_length = 24
    air_temp_header = Header(Temperature(), 'C', AnalysisPeriod(end_month=1, end_day=1))
    air_temp = HourlyContinuousCollection(air_temp_header, [24] * calc_length)
    custom_par = PMVParameter(15, 0.012, 0.004, 0.2)
    pmv_obj = PMV(air_temp, 50, 22, 0.5, 1.2, 0.85, 0.1, custom_par)

    assert pmv_obj.air_temperature[0] == 24
    assert pmv_obj.rel_humidity[0] == 50
    assert pmv_obj.rad_temperature[0] == 22
    assert pmv_obj.air_speed[0] == 0.5
    assert pmv_obj.met_rate[0] == 1.2
    assert pmv_obj.clo_value[0] == 0.85
    assert pmv_obj.external_work[0] == 0.1
    assert pmv_obj.comfort_parameter.ppd_comfort_thresh == 15
    assert pmv_obj.comfort_parameter.humid_ratio_upper == 0.012
    assert pmv_obj.comfort_parameter.humid_ratio_lower == 0.004
    assert pmv_obj.comfort_parameter.still_air_threshold == 0.2
コード例 #14
0
def test_night_flush_polygon():
    """Test the night_flush_polygon method."""
    # test the polygon with the default comfort settings
    path = './tests/epw/chicago.epw'
    epw = EPW(path)
    psych_chart = PsychrometricChart(epw.dry_bulb_temperature,
                                     epw.relative_humidity)
    poly_obj = PolygonPMV(psych_chart)
    nf_poly = poly_obj.night_flush_polygon()
    val_list = poly_obj.evaluate_night_flush_polygon(nf_poly,
                                                     epw.dry_bulb_temperature)
    assert 0 < sum(val_list) < 8760

    # test the polygon with custom comfort settings
    psych_chart = PsychrometricChart(30, 30, max_temperature=40)
    pmv_par = PMVParameter(humid_ratio_upper=0.008, humid_ratio_lower=0.005)
    poly_obj = PolygonPMV(psych_chart, comfort_parameter=pmv_par)
    nf_poly = poly_obj.night_flush_polygon(16)
    val_list = poly_obj.evaluate_night_flush_polygon(nf_poly, [20])
    assert val_list == [1]
コード例 #15
0
def test_pmv_collection_humidity_ratio_outputs():
    """Test the humudity ratio outputs of the PMV collection."""
    calc_length = 24
    air_temp_header = Header(Temperature(), 'C', AnalysisPeriod(end_month=1, end_day=1))
    air_temp = HourlyContinuousCollection(air_temp_header, [24] * calc_length)
    pmv_obj = PMV(air_temp, 90)

    assert isinstance(pmv_obj.humidity_ratio, HourlyContinuousCollection)
    assert len(pmv_obj.humidity_ratio.values) == calc_length
    assert pmv_obj.humidity_ratio[0] == pytest.approx(0.016939, rel=1e-3)

    hr_par = PMVParameter(humid_ratio_upper=0.012)
    pmv_obj = PMV(air_temp, 90, comfort_parameter=hr_par)
    assert pmv_obj._hr_calculated is True
    assert pmv_obj._hr_comfort_required is True

    assert pmv_obj.humidity_ratio[0] == pytest.approx(0.016939, rel=1e-3)
    assert pmv_obj.is_comfortable[0] == 0
    assert pmv_obj.thermal_condition[0] == 0
    assert pmv_obj.discomfort_reason[0] == 2
コード例 #16
0
        _hr_upper_: A number between 0 and 1 indicating the upper limit of
            humidity ratio that is considered acceptable.
            Default is 1 for essentially no limit.
        _hr_lower_: A number between 0 and 1 indicating the lower limit of
            humidity ratio considered acceptable.
            Default is 0 for essentially no limit.
        _still_air_thresh_: The air speed threshold in m/s at which the standard
            effective temperature (SET) model will be used to correct for the
            cooling effect of elevated air speeds.
            Default is 0.1 m/s, which is the limit according to ASHRAE-55.
    
    Returns:
        pmv_par: A PMV comfort parameter object that can be plugged into
            any of the components that compute PMV thermal comfort.
"""

ghenv.Component.Name = 'LB PMV Comfort Parameters'
ghenv.Component.NickName = 'PMVPar'
ghenv.Component.Message = '1.5.0'
ghenv.Component.Category = 'Ladybug'
ghenv.Component.SubCategory = '4 :: Extra'
ghenv.Component.AdditionalHelpFromDocStrings = '4'

try:
    from ladybug_comfort.parameter.pmv import PMVParameter
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_comfort:\n\t{}'.format(e))

pmv_par = PMVParameter(_ppd_thresh_, _hr_upper_, _hr_lower_,
                       _still_air_thresh_)
コード例 #17
0
            try:
                input_list[i] = float(input)
            except ValueError as e:
                raise TypeError('input {} is not valid. Expected float or '
                                'DataCollection. Got {}'.format(
                                    input, type(input)))
    return input_list, data_colls


if all_required_inputs(ghenv.Component) and _run is True:
    # Process inputs and assign defaults.
    input_list = [
        _air_temp, _mrt_, _air_speed_, _rel_humid, _met_rate_, _clothing_
    ]
    input, data_colls = extract_collections(input_list)
    pmv_par = pmv_par_ or PMVParameter()

    if data_colls == []:
        # The inputs are all individual values.
        pmv_result = predicted_mean_vote(input[0], float(input[1]), input[2],
                                         input[3], input[4], input[5], 0,
                                         pmv_par.still_air_threshold)
        pmv = pmv_result['pmv']
        ppd = pmv_result['ppd']
        set = pmv_result['set']
        hr = humid_ratio_from_db_rh(input[0], input[3])
        comfort = pmv_par.is_comfortable(pmv_result['ppd'], hr)
        condition = pmv_par.discomfort_reason(pmv_result['pmv'],
                                              pmv_result['ppd'])
        heat_loss = [
            pmv_result['heat_loss']['cond'], pmv_result['heat_loss']['sweat'],