def test_setback_comfort_success_HVAC(self): a = datetime.datetime(2014, 1, 1, 0, 0, 0, 0) b = datetime.datetime(2014, 1, 3, 6, 0, 0, 0) #delta = 6 hours base = set_up_datetimes(a, b, 21600) DAT = copy.deepcopy(base) DAT_temp = [0, 0, 0, 0, 0, 100, 100, 100, 100, 100] append_data_to_datetime(DAT, DAT_temp) IAT = copy.deepcopy(base) IAT_temp = [50, 50, 50, 50, 50, 80, 80, 80, 80, 80] append_data_to_datetime(IAT, IAT_temp) HVAC = copy.deepcopy(base) HVAC_stat = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] append_data_to_datetime(HVAC, HVAC_stat) # 24/7, no holidays op_hours = [[0, 23], [1, 2, 3, 4, 5, 6, 7], []] test_area = 5000 test_elec_cost = 10000 comfort_result, setback_result = comfort_and_setpoint(IAT, DAT, op_hours, \ test_area, test_elec_cost, HVAC) self.assertEqual(comfort_result, {}) self.assertEqual(setback_result, {})
def test_comfort_undercooling(self): a = datetime.datetime(2014, 1, 1, 0, 0, 0, 0) b = datetime.datetime(2014, 1, 3, 6, 0, 0, 0) #delta = 6 hours base = set_up_datetimes(a, b, 21600) DAT = copy.deepcopy(base) DAT_temp = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100] append_data_to_datetime(DAT, DAT_temp) IAT = copy.deepcopy(base) IAT_temp = [200, 200, 200, 200, 200, 200, 200, 200, 200, 200] append_data_to_datetime(IAT, IAT_temp) # 24/7, no holidays op_hours = [[0, 23], [1, 2, 3, 4, 5, 6, 7], []] test_area = 5000 test_elec_cost = 10000 comfort_result, setback_result = comfort_and_setpoint(IAT, DAT, op_hours, \ test_area, test_elec_cost) expected = { 'Problem': "Under-conditioning, thermostat cooling " + \ "setpoint is high.", 'Diagnostic': "More than 30 percent of the time, the cooling setpoint " + \ "during occupied hours was greater than 80F.", 'Recommendation': "Program your thermostats to decrease the cooling " + \ "setpoint to improve building comfort during occupied hours." } self.assertEqual(comfort_result, expected)
def test_comfort_overheating_HVAC(self): a = datetime.datetime(2014, 1, 1, 0, 0, 0, 0) b = datetime.datetime(2014, 1, 3, 6, 0, 0, 0) #delta = 6 hours base = set_up_datetimes(a, b, 21600) DAT = copy.deepcopy(base) DAT_temp = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100] append_data_to_datetime(DAT, DAT_temp) IAT = copy.deepcopy(base) IAT_temp = [80, 80, 80, 80, 80, 80, 80, 80, 80, 80] append_data_to_datetime(IAT, IAT_temp) HVAC = copy.deepcopy(base) HVAC_stat = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2] append_data_to_datetime(HVAC, HVAC_stat) # 24/7, no holidays op_hours = [[0, 23], [1, 2, 3, 4, 5, 6, 7], []] test_area = 5000 test_elec_cost = 10000 comfort_result, setback_result = comfort_and_setpoint(IAT, DAT, op_hours, \ test_area, test_elec_cost, HVAC) exp_heat_cost = (80 - 72) * 0.03 * 1 * 0.31 * 1 * test_elec_cost expected = { 'Problem': "Over-conditioning, thermostat heating " + \ "setpoint is high.", 'Diagnostic': "More than 30 percent of the time, the heating setpoint " + \ "during occupied hours was greater than 72F, a temperature that " + \ "is comfortable to most occupants.", 'Recommendation': "Program your thermostats to decrease the heating " + \ "setpoint during occupied hours.", 'Savings': round(exp_heat_cost, 2) } self.assertEqual(comfort_result, expected)
def test_setback_HVAC(self): a = datetime.datetime(2014, 1, 1, 0, 0, 0, 0) b = datetime.datetime(2014, 1, 3, 6, 0, 0, 0) #delta = 6 hours base = set_up_datetimes(a, b, 21600) DAT = copy.deepcopy(base) DAT_temp = [0, 0, 0, 0, 0, 100, 100, 100, 100, 100] append_data_to_datetime(DAT, DAT_temp) IAT = copy.deepcopy(base) IAT_temp = [50, 50, 50, 50, 50, 80, 80, 80, 80, 80] append_data_to_datetime(IAT, IAT_temp) HVAC = copy.deepcopy(base) HVAC_stat = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2] append_data_to_datetime(HVAC, HVAC_stat) # 24/7, no holidays op_hours = [[0, 23], [1, 2, 3, 4, 5, 6, 7], []] test_area = 5000 test_elec_cost = 10000 comfort_result, setback_result = comfort_and_setpoint(IAT, DAT, op_hours, \ test_area, test_elec_cost, HVAC) exp_cool_cost = (76 - 50) * 0.03 * 0.5 * 0.07 * 1 * test_elec_cost exp_heat_cost = (80 - 72) * 0.03 * 0.5 * 0.31 * 1 * test_elec_cost expected = { 'Problem': "Overly narrow separation between heating " + \ "and cooling setpoints.", 'Diagnostic': "During occupied hours, the cooling setpoint was lower " + \ "than 76F and the heating setpoint was greater than 72F.", 'Recommendation': "Adjust the heating and cooling setpoints so that " + \ "they differ by more than four degrees.", 'Savings': round(exp_cool_cost + exp_heat_cost, 2) } self.assertEqual(setback_result, expected)
def test_comfort_underheating_HVAC(self): a = datetime.datetime(2014, 1, 1, 0, 0, 0, 0) b = datetime.datetime(2014, 1, 3, 6, 0, 0, 0) #delta = 6 hours base = set_up_datetimes(a, b, 21600) DAT = copy.deepcopy(base) DAT_temp = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50] append_data_to_datetime(DAT, DAT_temp) IAT = copy.deepcopy(base) IAT_temp = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] append_data_to_datetime(IAT, IAT_temp) HVAC = copy.deepcopy(base) HVAC_stat = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2] append_data_to_datetime(HVAC, HVAC_stat) # 24/7, no holidays op_hours = [[0, 23], [1, 2, 3, 4, 5, 6, 7], []] test_area = 5000 test_elec_cost = 10000 comfort_result, setback_result = comfort_and_setpoint(IAT, DAT, op_hours, \ test_area, test_elec_cost, HVAC) exp_cool_cost = (76 - 50) * 0.03 * 0.5 * 0.07 * 1 * test_elec_cost exp_heat_cost = (80 - 72) * 0.03 * 0.5 * 0.31 * 1 * test_elec_cost expected = { 'Problem': "Under-conditioning - thermostat heating " + \ "setpoint is low.", 'Diagnostic': "For more than 30% of the time, the cooling setpoint " + \ "during occupied hours was less than 69 degrees F.", 'Recommendation': "Program thermostats to increase the heating " + \ "setpoint to improve building comfort during occupied hours." } self.assertEqual(comfort_result, expected)
def test_comfort_overcooling(self): a = datetime.datetime(2014, 1, 1, 0, 0, 0, 0) b = datetime.datetime(2014, 1, 3, 6, 0, 0, 0) #delta = 6 hours base = set_up_datetimes(a, b, 21600) DAT = copy.deepcopy(base) DAT_temp = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] append_data_to_datetime(DAT, DAT_temp) IAT = copy.deepcopy(base) IAT_temp = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50] append_data_to_datetime(IAT, IAT_temp) # 24/7, no holidays op_hours = [[0, 23], [1, 2, 3, 4, 5, 6, 7], []] test_area = 5000 test_elec_cost = 10000 comfort_result, setback_result = comfort_and_setpoint(IAT, DAT, op_hours, \ test_area, test_elec_cost) exp_cool_cost = (76 - 50) * 0.03 * 1 * 0.07 * 1 * test_elec_cost expected = { 'Problem': "Over-conditioning, thermostat cooling setpoint is low", 'Diagnostic': "More than 30 percent of the time, the cooling setpoint " + \ "during occupied hours was lower than 75F, a temperature that " + \ "is comfortable to most occupants", 'Recommendation': "Program your thermostats to increase the cooling " + \ "setpoint during occupied hours.", 'Savings': round(exp_cool_cost, 2) } self.assertEqual(comfort_result, expected)
def execute(self): # Called after User hits GO """ Calculates weather sensitivity using Spearman rank. Also, outputs data points for energy signature scatter plot. """ self.out.log("Starting Day Time Temperature Analysis", logging.INFO) self.out.log('@operating_sched'+str(self.operating_sched), logging.INFO) self.out.log('@building_area'+str(self.building_area), logging.INFO) self.out.log('@electricity_cost'+str(self.electricity_cost), logging.INFO) # Query the database zat_query = self.inp.get_query_sets('zat', exclude={'value':None}, wrap_for_merge=True, group_by='minute') dat_query = self.inp.get_query_sets('dat', exclude={'value':None}, wrap_for_merge=True, group_by='minute') oat_query = self.inp.get_query_sets('oat', exclude={'value':None}, wrap_for_merge=True, group_by='minute') status_query = self.inp.get_query_sets('hvacstatus', exclude={'value':None}, wrap_for_merge=True, group_by='minute') # Merge temperatures and the HVACStatus merged_temperatures_status = self.inp.merge(zat_query, oat_query, dat_query,status_query) # Get conversion factor base_topic = self.inp.get_topics() meta_topics = self.inp.get_topics_meta() zat_unit = meta_topics['zat'][base_topic['zat'][0]]['unit'] dat_unit = meta_topics['dat'][base_topic['dat'][0]]['unit'] oat_unit = meta_topics['oat'][base_topic['oat'][0]]['unit'] #From the merged values make the arrays for the models datetime_ZAT = [] datetime_DAT = [] datetime_OAT = [] datetime_HVACStatus = [] for line in merged_temperatures_status: # Convert datetime str to datetime obj datetimeObj = dt.datetime.strptime(line['time'],'%Y-%m-%d %H:%M') # Convert ZAT if zat_unit == 'celcius': convertedZAT = cu.convertCelciusToFahrenheit(line['zat'][0]) elif zat_unit == 'kelvin': convertedZAT = cu.convertKelvinToCelcius( cu.convertCelciusToFahrenheit(line['zat'][0])) else: convertedZAT = line['zat'][0] # datetime_ZAT.append((datetimeObj, convertedZAT)) # Convert DAT if dat_unit == 'celcius': convertedDAT = cu.convertCelciusToFahrenheit(line['dat'][0]) elif dat_unit == 'kelvin': convertedDAT = cu.convertKelvinToCelcius( cu.convertCelciusToFahrenheit(line['dat'][0])) else: convertedDAT = line['dat'][0] # datetime_DAT.append((datetimeObj, convertedDAT)) # Convert OAT if oat_unit == 'celcius': convertedOAT = cu.convertCelciusToFahrenheit(line['oat'][0]) elif oat_unit == 'kelvin': convertedOAT = cu.convertKelvinToCelcius( cu.convertCelciusToFahrenheit(line['oat'][0])) else: convertedOAT = line['oat'][0] # datetime_OAT.append((datetimeObj, convertedOAT)) # datetime_HVACStatus.append((datetimeObj, line['hvacstatus'][0])) # Apply the comfort_and_setpoint model. comfort_flag, setback_flag = cs.comfort_and_setpoint(datetime_ZAT, datetime_DAT, self.operating_sched, self.building_area, self.electricity_cost, datetime_HVACStatus) if comfort_flag != {}: self.out.insert_row('SensorSuitcaseHVAC', { 'analysis': 'Comfort Optimization', 'problem': comfort_flag['Problem'], 'diagnostic': comfort_flag['Diagnostic'], 'recommendation': comfort_flag['Recommendation'], 'savings': '${:.2f}'.format(comfort_flag['Savings']) }) if setback_flag != {}: self.out.insert_row('SensorSuitcaseHVAC', { 'analysis': 'Comfort Optimization', 'problem': setback_flag['Problem'], 'diagnostic': setback_flag['Diagnostic'], 'recommendation': setback_flag['Recommendation'], 'savings': '${:.2f}'.format(setback_flag['Savings']) }) # Apply the economizer model. economizer_flag = ecn.economizer(datetime_DAT, datetime_OAT, datetime_HVACStatus, self.electricity_cost, self.building_area) if economizer_flag != {}: self.out.insert_row('SensorSuitcaseHVAC', { 'analysis': 'Economizer Diagnostics', 'problem': economizer_flag['Problem'], 'diagnostic': economizer_flag['Diagnostic'], 'recommendation': economizer_flag['Recommendation'], 'savings': '${:.2f}'.format(economizer_flag['Savings']) }) # Apply the setback_non_op model. setback_nonop_flag = sb.setback_non_op(datetime_ZAT, datetime_DAT, self.operating_sched, self.electricity_cost, self.building_area, datetime_HVACStatus) if setback_nonop_flag != {}: self.out.insert_row('SensorSuitcaseHVAC', { 'analysis': 'Setback During Unoccupied Hours', 'problem': setback_nonop_flag['Problem'], 'diagnostic': setback_nonop_flag['Diagnostic'], 'recommendation': setback_nonop_flag['Recommendation'], 'savings': '${:.2f}'.format(setback_nonop_flag['Savings']) }) # Apply the short_cycling model. shortcycling_flag = shc.short_cycling(datetime_HVACStatus, self.electricity_cost) if shortcycling_flag != {}: self.out.insert_row('SensorSuitcaseHVAC', { 'analysis': 'Shortcycling', 'problem': shortcycling_flag['Problem'], 'diagnostic': shortcycling_flag['Diagnostic'], 'recommendation': shortcycling_flag['Recommendation'], 'savings': '${:.2f}'.format(shortcycling_flag['Savings']) })
def execute(self): # Called after User hits GO """ Calculates weather sensitivity using Spearman rank. Also, outputs data points for energy signature scatter plot. """ self.out.log("Starting application: Sensor Suitcase HVAC.", logging.INFO) self.out.log('@operating_sched' + str(self.operating_sched), logging.INFO) self.out.log('@building_area' + str(self.building_area), logging.INFO) self.out.log('@electricity_cost' + str(self.electricity_cost), logging.INFO) # Query the database zat_query = self.inp.get_query_sets('zat', exclude={'value': None}, wrap_for_merge=True, group_by='minute') dat_query = self.inp.get_query_sets('dat', exclude={'value': None}, wrap_for_merge=True, group_by='minute') oat_query = self.inp.get_query_sets('oat', exclude={'value': None}, wrap_for_merge=True, group_by='minute') status_query = self.inp.get_query_sets('hvacstatus', exclude={'value': None}, wrap_for_merge=True, group_by='minute') # Merge temperatures and the HVACStatus merged_temperatures_status = self.inp.merge(zat_query, oat_query, dat_query, status_query) self.out.log("Getting unit conversions.", logging.INFO) base_topic = self.inp.get_topics() meta_topics = self.inp.get_topics_meta() zat_unit = meta_topics['zat'][base_topic['zat'][0]]['unit'] self.out.log( "Convert zone air temperatures from [{}] to [F].".format(zat_unit), logging.INFO) dat_unit = meta_topics['dat'][base_topic['dat'][0]]['unit'] self.out.log( "Convert discharge air temperatures from [{}] to [F].".format( dat_unit), logging.INFO) oat_unit = meta_topics['oat'][base_topic['oat'][0]]['unit'] self.out.log( "Convert outside air temperatures from [{}] to [F].".format( oat_unit), logging.INFO) #From the merged values make the arrays for the models datetime_ZAT = [] datetime_DAT = [] datetime_OAT = [] datetime_HVACStatus = [] for line in merged_temperatures_status: # Convert datetime str to datetime obj # datetimeObj = dt.datetime.strptime(line['time'],'%Y-%m-%d %H:%M') datetimeObj = line['time'] # Convert ZAT if zat_unit == 'celcius': convertedZAT = cu.convertCelciusToFahrenheit(line['zat'][0]) elif zat_unit == 'kelvin': convertedZAT = cu.convertKelvinToCelcius( cu.convertCelciusToFahrenheit(line['zat'][0])) else: convertedZAT = line['zat'][0] # datetime_ZAT.append((datetimeObj, convertedZAT)) # Convert DAT if dat_unit == 'celcius': convertedDAT = cu.convertCelciusToFahrenheit(line['dat'][0]) elif dat_unit == 'kelvin': convertedDAT = cu.convertKelvinToCelcius( cu.convertCelciusToFahrenheit(line['dat'][0])) else: convertedDAT = line['dat'][0] # datetime_DAT.append((datetimeObj, convertedDAT)) # Convert OAT if oat_unit == 'celcius': convertedOAT = cu.convertCelciusToFahrenheit(line['oat'][0]) elif oat_unit == 'kelvin': convertedOAT = cu.convertKelvinToCelcius( cu.convertCelciusToFahrenheit(line['oat'][0])) else: convertedOAT = line['oat'][0] # datetime_OAT.append((datetimeObj, convertedOAT)) # datetime_HVACStatus.append((datetimeObj, line['hvacstatus'][0])) # Apply the comfort_and_setpoint model. comfort_flag, setback_flag = cs.comfort_and_setpoint( datetime_ZAT, datetime_DAT, self.operating_sched, self.building_area, self.electricity_cost, datetime_HVACStatus) if comfort_flag != {}: self.out.insert_row( 'SensorSuitcaseHVAC', { 'analysis': 'Comfort Optimization', 'problem': comfort_flag['Problem'], 'diagnostic': comfort_flag['Diagnostic'], 'recommendation': comfort_flag['Recommendation'], 'savings': '${:.2f}'.format(comfort_flag['Savings']) }) if setback_flag != {}: self.out.insert_row( 'SensorSuitcaseHVAC', { 'analysis': 'Comfort Optimization', 'problem': setback_flag['Problem'], 'diagnostic': setback_flag['Diagnostic'], 'recommendation': setback_flag['Recommendation'], 'savings': '${:.2f}'.format(setback_flag['Savings']) }) # Apply the economizer model. economizer_flag = ecn.economizer(datetime_DAT, datetime_OAT, datetime_HVACStatus, self.electricity_cost, self.building_area) if economizer_flag != {}: self.out.insert_row( 'SensorSuitcaseHVAC', { 'analysis': 'Economizer Diagnostics', 'problem': economizer_flag['Problem'], 'diagnostic': economizer_flag['Diagnostic'], 'recommendation': economizer_flag['Recommendation'], 'savings': '${:.2f}'.format(economizer_flag['Savings']) }) # Apply the setback_non_op model. setback_nonop_flag = sb.setback_non_op(datetime_ZAT, datetime_DAT, self.operating_sched, self.electricity_cost, self.building_area, datetime_HVACStatus) if setback_nonop_flag != {}: self.out.insert_row( 'SensorSuitcaseHVAC', { 'analysis': 'Setback During Unoccupied Hours', 'problem': setback_nonop_flag['Problem'], 'diagnostic': setback_nonop_flag['Diagnostic'], 'recommendation': setback_nonop_flag['Recommendation'], 'savings': '${:.2f}'.format(setback_nonop_flag['Savings']) }) # Apply the short_cycling model. shortcycling_flag = shc.short_cycling(datetime_HVACStatus, self.electricity_cost, self.building_area) if shortcycling_flag != {}: self.out.insert_row( 'SensorSuitcaseHVAC', { 'analysis': 'Shortcycling', 'problem': shortcycling_flag['Problem'], 'diagnostic': shortcycling_flag['Diagnostic'], 'recommendation': shortcycling_flag['Recommendation'], 'savings': '${:.2f}'.format(shortcycling_flag['Savings']) })