def test_adaptive_parameter_incorrect(): """Test incorrect AdaptiveParameter properties.""" with pytest.raises(Exception): AdaptiveParameter(neutral_offset=-2) with pytest.raises(Exception): AdaptiveParameter(neutral_offset=12) with pytest.raises(Exception): AdaptiveParameter(cold_prevail_temp_limit=5) with pytest.raises(Exception): AdaptiveParameter(cold_prevail_temp_limit=30) with pytest.raises(Exception): AdaptiveParameter(conditioning=50)
def test_adaptive_collection_immutability(): """Test that the Adaptive collection is immutable.""" calc_length = 24 prevail_header = Header(PrevailingOutdoorTemperature(), 'C', AnalysisPeriod(end_month=1, end_day=1)) prevail_temp = HourlyContinuousCollection(prevail_header, [22] * calc_length) op_temp_header = Header(Temperature(), 'C', AnalysisPeriod(end_month=1, end_day=1)) op_temp = HourlyContinuousCollection(op_temp_header, [26] * calc_length) adapt_obj = Adaptive(prevail_temp, op_temp) # check that editing the original collection does not mutate the object op_temp[0] = 28 assert adapt_obj.operative_temperature[0] == 26 # check that editing collection properties does not mutate the object with pytest.raises(Exception): adapt_obj.operative_temperature[0] = 28 with pytest.raises(Exception): adapt_obj.operative_temperature.values = [28] * calc_length with pytest.raises(Exception): adapt_obj.degrees_from_neutral[0] = 0.5 with pytest.raises(Exception): adapt_obj.degrees_from_neutral.values = [0.5] * calc_length # check that properties cannot be edited directly with pytest.raises(Exception): adapt_obj.operative_temperature = op_temp with pytest.raises(Exception): adapt_obj.degrees_from_neutral = op_temp with pytest.raises(Exception): adapt_obj.comfort_parameter = AdaptiveParameter(False)
def test_adaptive_parameter_default_ahsrae55(): """Test the default AdaptiveParameter properties.""" adaptive_par = AdaptiveParameter() str(adaptive_par) # test casting the parameters to a string assert adaptive_par.ashrae55_or_en15251 is True assert adaptive_par.neutral_offset == 2.5 assert adaptive_par.avg_month_or_running_mean is True assert adaptive_par.discrete_or_continuous_air_speed is True assert adaptive_par.cold_prevail_temp_limit == 10 assert adaptive_par.conditioning == 0 assert adaptive_par.standard == 'ASHRAE-55' assert adaptive_par.prevailing_temperature_method == 'Averaged Monthly' assert adaptive_par.air_speed_method == 'Discrete' assert adaptive_par.minimum_operative == pytest.approx(18.4, rel=1e-2) adaptive_par.set_neutral_offset_from_ppd(80) assert adaptive_par.neutral_offset == 3.5
def test_adaptive_parameter_default_en15251(): """Test the default AdaptiveParameter properties.""" adaptive_par = AdaptiveParameter(False) str(adaptive_par) # test casting the parameters to a string assert adaptive_par.ashrae55_or_en15251 is False assert adaptive_par.neutral_offset == 3 assert adaptive_par.avg_month_or_running_mean is False assert adaptive_par.discrete_or_continuous_air_speed is False assert adaptive_par.cold_prevail_temp_limit == 15 assert adaptive_par.conditioning == 0 assert adaptive_par.standard == 'EN-15251' assert adaptive_par.prevailing_temperature_method == 'Running Mean' assert adaptive_par.air_speed_method == 'Continuous' assert adaptive_par.minimum_operative == pytest.approx(20.75, rel=1e-2) adaptive_par.set_neutral_offset_from_comfort_class(1) assert adaptive_par.neutral_offset == 2
def _load_adaptive_par_str(comfort_par_str): """Load a AdaptiveParameter from a string. Args: comfort_par_str: A string of a AdaptiveParameter to be loaded. """ if comfort_par_str is not None and comfort_par_str != '' \ and comfort_par_str != 'None': return AdaptiveParameter.from_string(comfort_par_str)
def test_adaptive_by_room_custom(): runner = CliRunner() input_sql = './tests/sql/eplusout.sql' input_epw = './tests/epw/chicago.epw' air_speed = [0.65] * 8760 air_speed = json.dumps(air_speed) comf_par = AdaptiveParameter(False) comf_par.set_neutral_offset_from_comfort_class(1) result = runner.invoke( adaptive_by_room, [input_sql, input_epw, '-v', air_speed, '-cp', str(comf_par)]) assert result.exit_code == 0 data_dicts = json.loads(result.output) ad_data = [HourlyContinuousCollection.from_dict(dat) for dat in data_dicts] assert len(ad_data) == 2 assert len(ad_data[0]) == 8760
def test_adaptive_parameter_to_from_str(): """Test the AdaptiveParameter to/from str methods.""" adaptive_par = AdaptiveParameter(False) adaptive_par.set_neutral_offset_from_comfort_class(1) new_ad_comf = AdaptiveParameter.from_string(str(adaptive_par)) assert new_ad_comf.to_dict() == adaptive_par.to_dict()
def test_thermal_condition_check(): """Test the thermal condition check on AdaptiveParameter.""" comf_result = adaptive_comfort_ashrae55(24, 28) adaptive_par = AdaptiveParameter() condition_test = adaptive_par.thermal_condition(comf_result) assert condition_test == 1 comf_result = adaptive_comfort_ashrae55(24, 28) adaptive_par = AdaptiveParameter() condition_test = adaptive_par.thermal_condition(comf_result, 3) assert condition_test == 0
def test_comfort_check(): """Test comfort check on AdaptiveParameter.""" comf_result = adaptive_comfort_ashrae55(24, 28) adaptive_par = AdaptiveParameter() comf_test = adaptive_par.is_comfortable(comf_result) assert comf_test == 0 comf_result = adaptive_comfort_ashrae55(24, 28) adaptive_par = AdaptiveParameter() comf_test = adaptive_par.is_comfortable(comf_result, 3) assert comf_test == 1
def test_init_adaptive_collection_full_input(): """Test the initialization of the Adaptive collection will all inputs.""" calc_length = 24 prevail_header = Header(PrevailingOutdoorTemperature(), 'C', AnalysisPeriod(end_month=1, end_day=1)) prevail_temp = HourlyContinuousCollection(prevail_header, [22] * calc_length) op_temp_header = Header(Temperature(), 'C', AnalysisPeriod(end_month=1, end_day=1)) op_temp = HourlyContinuousCollection(op_temp_header, [26] * calc_length) custom_par = AdaptiveParameter(True, 2, False, False, 15, 0.25) adapt_obj = Adaptive(prevail_temp, op_temp, 0.7, custom_par) assert adapt_obj.operative_temperature[0] == 26 assert adapt_obj.air_speed[0] == 0.7 assert adapt_obj.comfort_parameter.ashrae55_or_en15251 is True assert adapt_obj.comfort_parameter.neutral_offset == 2 assert adapt_obj.comfort_parameter.avg_month_or_running_mean is False assert adapt_obj.comfort_parameter.discrete_or_continuous_air_speed is False assert adapt_obj.comfort_parameter.cold_prevail_temp_limit == 15 assert adapt_obj.comfort_parameter.conditioning == 0.25
def test_adaptive_parameter_init(): """Test the initialization of the AdaptiveParameter object.""" ashrae55_or_en15251 = False neutral_offset = 2 avg_month_or_run = True discr_or_cont = True cold_prevail_temp_limit = 18 conditioning = 0.5 adaptive_par = AdaptiveParameter( ashrae55_or_en15251=ashrae55_or_en15251, neutral_offset=neutral_offset, avg_month_or_running_mean=avg_month_or_run, discrete_or_continuous_air_speed=discr_or_cont, cold_prevail_temp_limit=cold_prevail_temp_limit, conditioning=conditioning) assert adaptive_par.ashrae55_or_en15251 == ashrae55_or_en15251 assert adaptive_par.neutral_offset == neutral_offset assert adaptive_par.avg_month_or_running_mean is avg_month_or_run assert adaptive_par.discrete_or_continuous_air_speed == discr_or_cont assert adaptive_par.cold_prevail_temp_limit == cold_prevail_temp_limit assert adaptive_par.conditioning == conditioning
def test_adaptive_collection_defaults(): """Test the default inputs assigned to the Adaptive collection.""" calc_length = 24 prevail_header = Header(PrevailingOutdoorTemperature(), 'C', AnalysisPeriod(end_month=1, end_day=1)) prevail_temp = HourlyContinuousCollection(prevail_header, [22] * calc_length) op_temp_header = Header(Temperature(), 'C', AnalysisPeriod(end_month=1, end_day=1)) op_temp = HourlyContinuousCollection(op_temp_header, [26] * calc_length) adapt_obj = Adaptive(prevail_temp, op_temp) assert isinstance(adapt_obj.air_speed, HourlyContinuousCollection) assert len(adapt_obj.air_speed.values) == calc_length assert adapt_obj.air_speed[0] == 0.1 assert isinstance(adapt_obj.comfort_parameter, AdaptiveParameter) default_par = AdaptiveParameter() assert adapt_obj.comfort_parameter.ashrae55_or_en15251 == default_par.ashrae55_or_en15251 assert adapt_obj.comfort_parameter.neutral_offset == default_par.neutral_offset assert adapt_obj.comfort_parameter.avg_month_or_running_mean == default_par.avg_month_or_running_mean assert adapt_obj.comfort_parameter.discrete_or_continuous_air_speed == default_par.discrete_or_continuous_air_speed assert adapt_obj.comfort_parameter.cold_prevail_temp_limit == default_par.cold_prevail_temp_limit assert adapt_obj.comfort_parameter.conditioning == default_par.conditioning
0 = free-running (completely passive with no air conditioning) 1 = conditioned (no operable windows and fully air conditioned) The default is 0 since both the ASHRAE-55 and EN-15251 standards prohibit the use of adaptive comfort methods when a heating/cooling system is active. When set to a non-zero number, a neutral temperature function for heated/cooled operation derived from the SCATs database will be used. For more information on how adaptive comfort methods can be applied to conditioned buildings, see the neutral_temperature_conditioned function in the ladybug_comfort documentation. Returns: adapt_par: An Adaptive comfort parameter object that can be plugged into any of the components that compute Adaptive thermal comfort. """ ghenv.Component.Name = 'LB Adaptive Comfort Parameters' ghenv.Component.NickName = 'AdaptPar' ghenv.Component.Message = '1.0.0' ghenv.Component.Category = 'Ladybug' ghenv.Component.SubCategory = '4 :: Extra' ghenv.Component.AdditionalHelpFromDocStrings = '4' try: from ladybug_comfort.parameter.adaptive import AdaptiveParameter except ImportError as e: raise ImportError('\nFailed to import ladybug_comfort:\n\t{}'.format(e)) adapt_par = AdaptiveParameter(_ashrae_or_en15251_, _neutral_offset_, _avgm_or_runmean_, _discr_or_cont_vel_, _cold_prevail_limit_, _conditioning_)
data_colls.append(input) else: 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 = [_out_temp, _air_temp, _mrt_, _air_speed_] input, data_colls = extract_collections(input_list) adapt_par = adapt_par_ or AdaptiveParameter() if data_colls == []: # The inputs are all individual values. prevail_temp = input[0] to = t_operative(input[1], float(input[2])) # Determine the ralationship to the neutral temperature if adapt_par.conditioning != 0: comf_result = adaptive_comfort_conditioned(prevail_temp, to, adapt_par.conditioning, adapt_par.standard) elif adapt_par.ashrae55_or_en15251 is True: comf_result = adaptive_comfort_ashrae55(prevail_temp, to) else: comf_result = adaptive_comfort_en15251(prevail_temp, to)