Merge pull request 'fixing_working_hours_problem' (#47) from fixing_working_hours_problem into main
Reviewed-on: https://nextgenerations-cities.encs.concordia.ca/gitea/CERC/hub/pulls/47
This commit is contained in:
commit
568317ebf1
|
@ -684,11 +684,17 @@ class Building(CityObject):
|
||||||
for i, value in enumerate(item):
|
for i, value in enumerate(item):
|
||||||
_working_hours[key][i] = max(_working_hours[key][i], saved_values[i])
|
_working_hours[key][i] = max(_working_hours[key][i], saved_values[i])
|
||||||
|
|
||||||
_total_hours = 0
|
working_hours = {}
|
||||||
for key in _working_hours:
|
values_months = []
|
||||||
hours = sum(_working_hours[key])
|
for month in cte.WEEK_DAYS_A_MONTH.keys():
|
||||||
_total_hours += hours * cte.WEEK_DAYS_A_YEAR[key]
|
_total_hours_month = 0
|
||||||
return _total_hours
|
for key in _working_hours:
|
||||||
|
hours = sum(_working_hours[key])
|
||||||
|
_total_hours_month += hours * cte.WEEK_DAYS_A_MONTH[month][key]
|
||||||
|
values_months.append(_total_hours_month)
|
||||||
|
working_hours[cte.MONTH] = values_months
|
||||||
|
working_hours[cte.YEAR] = sum(working_hours[cte.MONTH])
|
||||||
|
return working_hours
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def distribution_systems_electrical_consumption(self):
|
def distribution_systems_electrical_consumption(self):
|
||||||
|
@ -738,7 +744,7 @@ class Building(CityObject):
|
||||||
for key, item in self._distribution_systems_electrical_consumption.items():
|
for key, item in self._distribution_systems_electrical_consumption.items():
|
||||||
for i in range(0, len(item)):
|
for i in range(0, len(item)):
|
||||||
self._distribution_systems_electrical_consumption[key][i] += _peak_load * _consumption_fix_flow \
|
self._distribution_systems_electrical_consumption[key][i] += _peak_load * _consumption_fix_flow \
|
||||||
* _working_hours
|
* _working_hours[key] * cte.WATTS_HOUR_TO_JULES
|
||||||
return self._distribution_systems_electrical_consumption
|
return self._distribution_systems_electrical_consumption
|
||||||
|
|
||||||
def _calculate_consumption(self, consumption_type, demand):
|
def _calculate_consumption(self, consumption_type, demand):
|
||||||
|
|
|
@ -49,36 +49,140 @@ WEEK_DAYS = 'Weekdays'
|
||||||
WEEK_ENDS = 'Weekends'
|
WEEK_ENDS = 'Weekends'
|
||||||
ALL_DAYS = 'Alldays'
|
ALL_DAYS = 'Alldays'
|
||||||
|
|
||||||
WEEK_DAYS_A_MONTH = {'monday': [5, 4, 4, 5, 4, 4, 5, 4, 4, 5, 4, 5],
|
JANUARY = 'January'
|
||||||
'tuesday': [5, 4, 4, 4, 5, 4, 5, 4, 4, 5, 4, 4],
|
FEBRUARY = 'February'
|
||||||
'wednesday': [5, 4, 4, 4, 5, 4, 4, 5, 4, 5, 4, 4],
|
MARCH = 'March'
|
||||||
'thursday': [4, 4, 5, 4, 5, 4, 4, 5, 4, 4, 5, 4],
|
APRIL = 'April'
|
||||||
'friday': [4, 4, 5, 4, 4, 5, 4, 5, 4, 4, 5, 4],
|
MAY = 'May'
|
||||||
'saturday': [4, 4, 5, 4, 4, 5, 4, 4, 5, 4, 4, 5],
|
JUNE = 'June'
|
||||||
'sunday': [4, 4, 4, 5, 4, 4, 5, 4, 5, 4, 4, 5],
|
JULY = 'July'
|
||||||
'holiday': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}
|
AUGUST = 'August'
|
||||||
|
SEPTEMBER = 'September'
|
||||||
|
OCTOBER = 'October'
|
||||||
|
NOVEMBER = 'November'
|
||||||
|
DECEMBER = 'December'
|
||||||
|
|
||||||
WEEK_DAYS_A_YEAR = {'monday': 51,
|
MONTHS = [JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER]
|
||||||
'tuesday': 50,
|
|
||||||
'wednesday': 50,
|
|
||||||
'thursday': 50,
|
|
||||||
'friday': 50,
|
|
||||||
'saturday': 52,
|
|
||||||
'sunday': 52,
|
|
||||||
'holiday': 10}
|
|
||||||
|
|
||||||
DAYS_A_MONTH = {'January': 31,
|
WEEK_DAYS_A_MONTH = {JANUARY: {MONDAY: 5,
|
||||||
'February': 28,
|
TUESDAY: 5,
|
||||||
'March': 31,
|
WEDNESDAY: 5,
|
||||||
'April': 30,
|
THURSDAY: 4,
|
||||||
'May': 31,
|
FRIDAY: 4,
|
||||||
'June': 30,
|
SATURDAY: 4,
|
||||||
'July': 31,
|
SUNDAY: 4,
|
||||||
'August': 31,
|
HOLIDAY: 0},
|
||||||
'September': 30,
|
FEBRUARY: {MONDAY: 4,
|
||||||
'October': 31,
|
TUESDAY: 4,
|
||||||
'November': 30,
|
WEDNESDAY: 4,
|
||||||
'December': 31}
|
THURSDAY: 4,
|
||||||
|
FRIDAY: 4,
|
||||||
|
SATURDAY: 4,
|
||||||
|
SUNDAY: 4,
|
||||||
|
HOLIDAY: 0},
|
||||||
|
MARCH: {MONDAY: 4,
|
||||||
|
TUESDAY: 4,
|
||||||
|
WEDNESDAY: 4,
|
||||||
|
THURSDAY: 5,
|
||||||
|
FRIDAY: 5,
|
||||||
|
SATURDAY: 5,
|
||||||
|
SUNDAY: 4,
|
||||||
|
HOLIDAY: 0},
|
||||||
|
APRIL: {MONDAY: 5,
|
||||||
|
TUESDAY: 4,
|
||||||
|
WEDNESDAY: 4,
|
||||||
|
THURSDAY: 4,
|
||||||
|
FRIDAY: 4,
|
||||||
|
SATURDAY: 4,
|
||||||
|
SUNDAY: 5,
|
||||||
|
HOLIDAY: 0},
|
||||||
|
MAY: {MONDAY: 4,
|
||||||
|
TUESDAY: 5,
|
||||||
|
WEDNESDAY: 5,
|
||||||
|
THURSDAY: 5,
|
||||||
|
FRIDAY: 4,
|
||||||
|
SATURDAY: 4,
|
||||||
|
SUNDAY: 4,
|
||||||
|
HOLIDAY: 0},
|
||||||
|
JUNE: {MONDAY: 4,
|
||||||
|
TUESDAY: 4,
|
||||||
|
WEDNESDAY: 4,
|
||||||
|
THURSDAY: 4,
|
||||||
|
FRIDAY: 5,
|
||||||
|
SATURDAY: 5,
|
||||||
|
SUNDAY: 4,
|
||||||
|
HOLIDAY: 0},
|
||||||
|
JULY: {MONDAY: 5,
|
||||||
|
TUESDAY: 5,
|
||||||
|
WEDNESDAY: 4,
|
||||||
|
THURSDAY: 4,
|
||||||
|
FRIDAY: 4,
|
||||||
|
SATURDAY: 4,
|
||||||
|
SUNDAY: 5,
|
||||||
|
HOLIDAY: 0},
|
||||||
|
AUGUST: {MONDAY: 4,
|
||||||
|
TUESDAY: 4,
|
||||||
|
WEDNESDAY: 5,
|
||||||
|
THURSDAY: 5,
|
||||||
|
FRIDAY: 5,
|
||||||
|
SATURDAY: 4,
|
||||||
|
SUNDAY: 4,
|
||||||
|
HOLIDAY: 0},
|
||||||
|
SEPTEMBER: {MONDAY: 4,
|
||||||
|
TUESDAY: 4,
|
||||||
|
WEDNESDAY: 4,
|
||||||
|
THURSDAY: 4,
|
||||||
|
FRIDAY: 4,
|
||||||
|
SATURDAY: 5,
|
||||||
|
SUNDAY: 5,
|
||||||
|
HOLIDAY: 0},
|
||||||
|
OCTOBER: {MONDAY: 5,
|
||||||
|
TUESDAY: 5,
|
||||||
|
WEDNESDAY: 5,
|
||||||
|
THURSDAY: 4,
|
||||||
|
FRIDAY: 4,
|
||||||
|
SATURDAY: 4,
|
||||||
|
SUNDAY: 4,
|
||||||
|
HOLIDAY: 0},
|
||||||
|
NOVEMBER: {MONDAY: 4,
|
||||||
|
TUESDAY: 4,
|
||||||
|
WEDNESDAY: 4,
|
||||||
|
THURSDAY: 5,
|
||||||
|
FRIDAY: 5,
|
||||||
|
SATURDAY: 4,
|
||||||
|
SUNDAY: 4,
|
||||||
|
HOLIDAY: 0},
|
||||||
|
DECEMBER: {MONDAY: 5,
|
||||||
|
TUESDAY: 4,
|
||||||
|
WEDNESDAY: 4,
|
||||||
|
THURSDAY: 4,
|
||||||
|
FRIDAY: 4,
|
||||||
|
SATURDAY: 5,
|
||||||
|
SUNDAY: 5,
|
||||||
|
HOLIDAY: 0},
|
||||||
|
}
|
||||||
|
|
||||||
|
WEEK_DAYS_A_YEAR = {MONDAY: 51,
|
||||||
|
TUESDAY: 50,
|
||||||
|
WEDNESDAY: 50,
|
||||||
|
THURSDAY: 50,
|
||||||
|
FRIDAY: 50,
|
||||||
|
SATURDAY: 52,
|
||||||
|
SUNDAY: 52,
|
||||||
|
HOLIDAY: 10}
|
||||||
|
|
||||||
|
DAYS_A_MONTH = {JANUARY: 31,
|
||||||
|
FEBRUARY: 28,
|
||||||
|
MARCH: 31,
|
||||||
|
APRIL: 30,
|
||||||
|
MAY: 31,
|
||||||
|
JUNE: 30,
|
||||||
|
JULY: 31,
|
||||||
|
AUGUST: 31,
|
||||||
|
SEPTEMBER: 30,
|
||||||
|
OCTOBER: 31,
|
||||||
|
NOVEMBER: 30,
|
||||||
|
DECEMBER: 31}
|
||||||
|
|
||||||
# data types
|
# data types
|
||||||
ANY_NUMBER = 'any_number'
|
ANY_NUMBER = 'any_number'
|
||||||
|
|
|
@ -59,7 +59,7 @@ class InselMonthlyEnergyBalance:
|
||||||
lighting_density = thermal_zone.lighting.density
|
lighting_density = thermal_zone.lighting.density
|
||||||
appliances_density = thermal_zone.appliances.density
|
appliances_density = thermal_zone.appliances.density
|
||||||
|
|
||||||
for month in range(0, 12):
|
for i_month, month in enumerate(cte.MONTHS):
|
||||||
total_dhw_demand = 0
|
total_dhw_demand = 0
|
||||||
total_lighting = 0
|
total_lighting = 0
|
||||||
total_appliances = 0
|
total_appliances = 0
|
||||||
|
@ -69,7 +69,7 @@ class InselMonthlyEnergyBalance:
|
||||||
for value in schedule.values:
|
for value in schedule.values:
|
||||||
total_day += value
|
total_day += value
|
||||||
for day_type in schedule.day_types:
|
for day_type in schedule.day_types:
|
||||||
total_lighting += total_day * cte.WEEK_DAYS_A_MONTH[day_type][month] \
|
total_lighting += total_day * cte.WEEK_DAYS_A_MONTH[month][day_type] \
|
||||||
* lighting_density / cte.WATTS_HOUR_TO_JULES
|
* lighting_density / cte.WATTS_HOUR_TO_JULES
|
||||||
lighting_demand.append(total_lighting * area)
|
lighting_demand.append(total_lighting * area)
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class InselMonthlyEnergyBalance:
|
||||||
for value in schedule.values:
|
for value in schedule.values:
|
||||||
total_day += value
|
total_day += value
|
||||||
for day_type in schedule.day_types:
|
for day_type in schedule.day_types:
|
||||||
total_appliances += total_day * cte.WEEK_DAYS_A_MONTH[day_type][month] \
|
total_appliances += total_day * cte.WEEK_DAYS_A_MONTH[month][day_type] \
|
||||||
* appliances_density / cte.WATTS_HOUR_TO_JULES
|
* appliances_density / cte.WATTS_HOUR_TO_JULES
|
||||||
appliances_demand.append(total_appliances * area)
|
appliances_demand.append(total_appliances * area)
|
||||||
|
|
||||||
|
@ -89,9 +89,9 @@ class InselMonthlyEnergyBalance:
|
||||||
for day_type in schedule.day_types:
|
for day_type in schedule.day_types:
|
||||||
demand = (
|
demand = (
|
||||||
peak_flow * cte.WATER_DENSITY * cte.WATER_HEAT_CAPACITY
|
peak_flow * cte.WATER_DENSITY * cte.WATER_HEAT_CAPACITY
|
||||||
* (service_temperature - cold_water[month]) / cte.WATTS_HOUR_TO_JULES
|
* (service_temperature - cold_water[i_month]) / cte.WATTS_HOUR_TO_JULES
|
||||||
)
|
)
|
||||||
total_dhw_demand += total_day * cte.WEEK_DAYS_A_MONTH[day_type][month] * demand
|
total_dhw_demand += total_day * cte.WEEK_DAYS_A_MONTH[month][day_type] * demand
|
||||||
domestic_hot_water_demand.append(total_dhw_demand * area)
|
domestic_hot_water_demand.append(total_dhw_demand * area)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
domestic_hot_water_demand = [0] * 12
|
domestic_hot_water_demand = [0] * 12
|
||||||
|
|
|
@ -40,7 +40,7 @@ class TestResultsImport(TestCase):
|
||||||
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
||||||
|
|
||||||
ConstructionFactory('nrcan', self._city).enrich()
|
ConstructionFactory('nrcan', self._city).enrich()
|
||||||
UsageFactory('nrcan', self._city).enrich()
|
UsageFactory('comnet', self._city).enrich()
|
||||||
|
|
||||||
def test_sra_import(self):
|
def test_sra_import(self):
|
||||||
ExportsFactory('sra', self._city, self._output_path).export()
|
ExportsFactory('sra', self._city, self._output_path).export()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user