Refactor in building.
heating and cooling are now heating_demand and cooling_demand
This commit is contained in:
parent
c6b986ad1b
commit
5e969986fb
|
@ -46,8 +46,8 @@ class Building(CityObject):
|
|||
self._aliases = None
|
||||
self._type = 'building'
|
||||
self._cold_water_temperature = {}
|
||||
self._heating = {}
|
||||
self._cooling = {}
|
||||
self._heating_demand = {}
|
||||
self._cooling_demand = {}
|
||||
self._lighting_electrical_demand = {}
|
||||
self._appliances_electrical_demand = {}
|
||||
self._domestic_hot_water_heat_demand = {}
|
||||
|
@ -291,15 +291,15 @@ class Building(CityObject):
|
|||
self._cold_water_temperature = value
|
||||
|
||||
@property
|
||||
def heating(self) -> dict:
|
||||
def heating_demand(self) -> dict:
|
||||
"""
|
||||
Get heating demand in Wh
|
||||
:return: dict{DataFrame(float)}
|
||||
"""
|
||||
return self._heating
|
||||
return self._heating_demand
|
||||
|
||||
@heating.setter
|
||||
def heating(self, value):
|
||||
@heating_demand.setter
|
||||
def heating_demand(self, value):
|
||||
"""
|
||||
Set heating demand in Wh
|
||||
:param value: dict{DataFrame(float)}
|
||||
|
@ -307,15 +307,15 @@ class Building(CityObject):
|
|||
self._heating = value
|
||||
|
||||
@property
|
||||
def cooling(self) -> dict:
|
||||
def cooling_demand(self) -> dict:
|
||||
"""
|
||||
Get cooling demand in Wh
|
||||
:return: dict{DataFrame(float)}
|
||||
"""
|
||||
return self._cooling
|
||||
return self._cooling_demand
|
||||
|
||||
@cooling.setter
|
||||
def cooling(self, value):
|
||||
@cooling_demand.setter
|
||||
def cooling_demand(self, value):
|
||||
"""
|
||||
Set cooling demand in Wh
|
||||
:param value: dict{DataFrame(float)}
|
||||
|
@ -377,9 +377,9 @@ class Building(CityObject):
|
|||
:return: dict{DataFrame(float)}
|
||||
"""
|
||||
results = {}
|
||||
if cte.HOUR in self.heating:
|
||||
if cte.HOUR in self.heating_demand:
|
||||
monthly_values = PeakLoads().\
|
||||
peak_loads_from_hourly(self.heating[cte.HOUR][next(iter(self.heating[cte.HOUR]))])
|
||||
peak_loads_from_hourly(self.heating_demand[cte.HOUR][next(iter(self.heating_demand[cte.HOUR]))])
|
||||
else:
|
||||
monthly_values = PeakLoads(self).heating_peak_loads_from_methodology
|
||||
if monthly_values is None:
|
||||
|
@ -395,8 +395,8 @@ class Building(CityObject):
|
|||
:return: dict{DataFrame(float)}
|
||||
"""
|
||||
results = {}
|
||||
if cte.HOUR in self.cooling:
|
||||
monthly_values = PeakLoads().peak_loads_from_hourly(self.cooling[cte.HOUR][next(iter(self.cooling[cte.HOUR]))])
|
||||
if cte.HOUR in self.cooling_demand:
|
||||
monthly_values = PeakLoads().peak_loads_from_hourly(self.cooling_demand[cte.HOUR][next(iter(self.cooling_demand[cte.HOUR]))])
|
||||
else:
|
||||
monthly_values = PeakLoads(self).cooling_peak_loads_from_methodology
|
||||
if monthly_values is None:
|
||||
|
@ -562,8 +562,8 @@ class Building(CityObject):
|
|||
return: dict
|
||||
"""
|
||||
if len(self._heating_consumption) == 0:
|
||||
for heating_demand_key in self.heating:
|
||||
demand = self.heating[heating_demand_key][cte.INSEL_MEB]
|
||||
for heating_demand_key in self.heating_demand:
|
||||
demand = self.heating_demand[heating_demand_key][cte.INSEL_MEB]
|
||||
consumption_type = cte.HEATING
|
||||
final_energy_consumed = self._calculate_consumption(consumption_type, demand)
|
||||
if final_energy_consumed is None:
|
||||
|
@ -578,8 +578,8 @@ class Building(CityObject):
|
|||
return: dict
|
||||
"""
|
||||
if len(self._cooling_consumption) == 0:
|
||||
for cooling_demand_key in self.cooling:
|
||||
demand = self.cooling[cooling_demand_key][cte.INSEL_MEB]
|
||||
for cooling_demand_key in self.cooling_demand:
|
||||
demand = self.cooling_demand[cooling_demand_key][cte.INSEL_MEB]
|
||||
consumption_type = cte.COOLING
|
||||
final_energy_consumed = self._calculate_consumption(consumption_type, demand)
|
||||
if final_energy_consumed is None:
|
||||
|
@ -658,18 +658,18 @@ class Building(CityObject):
|
|||
if demand_type.lower() == cte.HEATING.lower():
|
||||
if _peak_load_type == cte.HEATING.lower():
|
||||
_consumption_fix_flow = distribution_system.distribution_consumption_fix_flow
|
||||
for heating_demand_key in self.heating:
|
||||
_consumption = [0]*len(self.heating[heating_demand_key][cte.INSEL_MEB])
|
||||
_demand = self.heating[heating_demand_key][cte.INSEL_MEB]
|
||||
for heating_demand_key in self.heating_demand:
|
||||
_consumption = [0]*len(self.heating_demand[heating_demand_key][cte.INSEL_MEB])
|
||||
_demand = self.heating_demand[heating_demand_key][cte.INSEL_MEB]
|
||||
for i, _ in enumerate(_consumption):
|
||||
_consumption[i] += (parasitic_energy_consumption + consumption_variable_flow) * _demand[i]
|
||||
self._distribution_systems_electrical_consumption[heating_demand_key] = _consumption
|
||||
if demand_type.lower() == cte.COOLING.lower():
|
||||
if _peak_load_type == cte.COOLING.lower():
|
||||
_consumption_fix_flow = distribution_system.distribution_consumption_fix_flow
|
||||
for demand_key in self.cooling:
|
||||
for demand_key in self.cooling_demand:
|
||||
_consumption = self._distribution_systems_electrical_consumption[demand_key]
|
||||
_demand = self.cooling[demand_key][cte.INSEL_MEB]
|
||||
_demand = self.cooling_demand[demand_key][cte.INSEL_MEB]
|
||||
for i, _ in enumerate(_consumption):
|
||||
_consumption[i] += (parasitic_energy_consumption + consumption_variable_flow) * _demand[i]
|
||||
self._distribution_systems_electrical_consumption[demand_key] = _consumption
|
||||
|
|
|
@ -117,11 +117,11 @@ class InselMonthlyEnergyBalance:
|
|||
file_name = building.name + '.out'
|
||||
insel_output_file_path = Path(self._base_path / file_name).resolve()
|
||||
if insel_output_file_path.is_file():
|
||||
building.heating[cte.MONTH], building.cooling[cte.MONTH] = self._conditioning_demand(insel_output_file_path)
|
||||
building.heating[cte.YEAR] = pd.DataFrame(
|
||||
[building.heating[cte.MONTH][cte.INSEL_MEB].astype(float).sum()], columns=[cte.INSEL_MEB]
|
||||
building.heating_demand[cte.MONTH], building.cooling_demand[cte.MONTH] = self._conditioning_demand(insel_output_file_path)
|
||||
building.heating_demand[cte.YEAR] = pd.DataFrame(
|
||||
[building.heating_demand[cte.MONTH][cte.INSEL_MEB].astype(float).sum()], columns=[cte.INSEL_MEB]
|
||||
)
|
||||
building.cooling[cte.YEAR] = pd.DataFrame(
|
||||
[building.cooling[cte.MONTH][cte.INSEL_MEB].astype(float).sum()], columns=[cte.INSEL_MEB]
|
||||
building.cooling_demand[cte.YEAR] = pd.DataFrame(
|
||||
[building.cooling_demand[cte.MONTH][cte.INSEL_MEB].astype(float).sum()], columns=[cte.INSEL_MEB]
|
||||
)
|
||||
self._dhw_and_electric_demand()
|
||||
|
|
|
@ -96,8 +96,8 @@ class TestConstructionFactory(TestCase):
|
|||
self.assertIsNotNone(building.function, 'building function is none')
|
||||
self.assertIsNotNone(building.average_storey_height, 'building average_storey_height is none')
|
||||
self.assertIsNotNone(building.storeys_above_ground, 'building storeys_above_ground is none')
|
||||
self.assertEqual(len(building.heating), 0, 'building heating is not none')
|
||||
self.assertEqual(len(building.cooling), 0, 'building cooling is not none')
|
||||
self.assertEqual(len(building.heating_demand), 0, 'building heating is not none')
|
||||
self.assertEqual(len(building.cooling_demand), 0, 'building cooling is not none')
|
||||
self.assertIsNotNone(building.eave_height, 'building eave height is none')
|
||||
self.assertIsNotNone(building.roof_type, 'building roof type is none')
|
||||
self.assertIsNotNone(building.floor_area, 'building floor_area is none')
|
||||
|
|
|
@ -198,17 +198,17 @@ TestDBFactory
|
|||
city_objects_id = []
|
||||
for building in control.city.buildings:
|
||||
_building = control.database.building_info(building.name, city_id)
|
||||
if cte.MONTH not in building.cooling:
|
||||
if cte.MONTH not in building.cooling_demand:
|
||||
print(f'building {building.name} not calculated')
|
||||
continue
|
||||
monthly_cooling_peak_load = building.cooling_peak_load[cte.MONTH]
|
||||
yearly_cooling_peak_load = building.cooling_peak_load[cte.YEAR]
|
||||
monthly_heating_peak_load = building.heating_peak_load[cte.MONTH]
|
||||
yearly_heating_peak_load = building.heating_peak_load[cte.YEAR]
|
||||
monthly_cooling_demand = building.cooling[cte.MONTH][cte.INSEL_MEB]
|
||||
yearly_cooling_demand = building.cooling[cte.YEAR][cte.INSEL_MEB]
|
||||
monthly_heating_demand = building.heating[cte.MONTH][cte.INSEL_MEB]
|
||||
yearly_heating_demand = building.heating[cte.YEAR][cte.INSEL_MEB]
|
||||
monthly_cooling_demand = building.cooling_demand[cte.MONTH][cte.INSEL_MEB]
|
||||
yearly_cooling_demand = building.cooling_demand[cte.YEAR][cte.INSEL_MEB]
|
||||
monthly_heating_demand = building.heating_demand[cte.MONTH][cte.INSEL_MEB]
|
||||
yearly_heating_demand = building.heating_demand[cte.YEAR][cte.INSEL_MEB]
|
||||
monthly_lighting_electrical_demand = building.lighting_electrical_demand[cte.MONTH][cte.INSEL_MEB]
|
||||
yearly_lighting_electrical_demand = building.lighting_electrical_demand[cte.YEAR][cte.INSEL_MEB]
|
||||
monthly_appliances_electrical_demand = building.appliances_electrical_demand[cte.MONTH][cte.INSEL_MEB]
|
||||
|
|
|
@ -58,10 +58,10 @@ class TestExports(TestCase):
|
|||
self._complete_city.climate_reference_city = 'Summerland'
|
||||
dummy_measures = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
|
||||
for building in self._complete_city.buildings:
|
||||
building.heating[cte.MONTH] = pd.DataFrame({'INSEL': dummy_measures})
|
||||
building.cooling[cte.MONTH] = pd.DataFrame({'INSEL': dummy_measures})
|
||||
building.heating[cte.YEAR] = pd.DataFrame({'INSEL': [0.0]})
|
||||
building.cooling[cte.YEAR] = pd.DataFrame({'INSEL': [0.0]})
|
||||
building.heating_demand[cte.MONTH] = pd.DataFrame({'INSEL': dummy_measures})
|
||||
building.cooling_demand[cte.MONTH] = pd.DataFrame({'INSEL': dummy_measures})
|
||||
building.heating_demand[cte.YEAR] = pd.DataFrame({'INSEL': [0.0]})
|
||||
building.cooling_demand[cte.YEAR] = pd.DataFrame({'INSEL': [0.0]})
|
||||
return self._complete_city
|
||||
|
||||
def _export(self, export_type, from_pickle=False):
|
||||
|
|
|
@ -68,8 +68,8 @@ class TestGeometryFactory(TestCase):
|
|||
self.assertIsNone(building.terrains, 'building terrains is not none')
|
||||
self.assertIsNone(building.average_storey_height, 'building average_storey_height is not none')
|
||||
self.assertIsNone(building.storeys_above_ground, 'building storeys_above_ground is not none')
|
||||
self.assertEqual(len(building.heating), 0, 'building heating is not none')
|
||||
self.assertEqual(len(building.cooling), 0, 'building cooling is not none')
|
||||
self.assertEqual(len(building.heating_demand), 0, 'building heating is not none')
|
||||
self.assertEqual(len(building.cooling_demand), 0, 'building cooling is not none')
|
||||
self.assertIsNotNone(building.eave_height, 'building eave height is none')
|
||||
self.assertIsNotNone(building.roof_type, 'building roof type is none')
|
||||
self.assertIsNotNone(building.floor_area, 'building floor_area is none')
|
||||
|
|
|
@ -62,10 +62,10 @@ class TestResultsImport(TestCase):
|
|||
ResultFactory('insel_monthly_energy_balance', self._city, self._output_path).enrich()
|
||||
# Check that all the buildings have heating and cooling values
|
||||
for building in self._city.buildings:
|
||||
self.assertIsNotNone(building.heating[cte.MONTH][cte.INSEL_MEB])
|
||||
self.assertIsNotNone(building.cooling[cte.MONTH][cte.INSEL_MEB])
|
||||
self.assertIsNotNone(building.heating[cte.YEAR][cte.INSEL_MEB])
|
||||
self.assertIsNotNone(building.cooling[cte.YEAR][cte.INSEL_MEB])
|
||||
self.assertIsNotNone(building.heating_demand[cte.MONTH][cte.INSEL_MEB])
|
||||
self.assertIsNotNone(building.cooling_demand[cte.MONTH][cte.INSEL_MEB])
|
||||
self.assertIsNotNone(building.heating_demand[cte.YEAR][cte.INSEL_MEB])
|
||||
self.assertIsNotNone(building.cooling_demand[cte.YEAR][cte.INSEL_MEB])
|
||||
|
||||
def test_peak_loads(self):
|
||||
# todo: this is not technically a import
|
||||
|
@ -83,7 +83,7 @@ class TestResultsImport(TestCase):
|
|||
expected_monthly_list = [0 for _ in range(12)]
|
||||
expected_monthly_list[0] = 1000
|
||||
for building in self._city.buildings:
|
||||
building.heating[cte.HOUR] = pd.DataFrame(values, columns=['dummy'])
|
||||
building.cooling[cte.HOUR] = pd.DataFrame(values, columns=['dummy'])
|
||||
building.heating_demand[cte.HOUR] = pd.DataFrame(values, columns=['dummy'])
|
||||
building.cooling_demand[cte.HOUR] = pd.DataFrame(values, columns=['dummy'])
|
||||
self.assertIsNotNone(building.heating_peak_load)
|
||||
self.assertIsNotNone(building.cooling_peak_load)
|
||||
|
|
|
@ -109,6 +109,6 @@ class TestSystemsFactory(TestCase):
|
|||
|
||||
for building in self._city.buildings:
|
||||
self.assertLess(0, building.heating_consumption[cte.YEAR][0])
|
||||
self.assertEqual(0, building.cooling_consumption[cte.YEAR][0])
|
||||
self.assertLess(0, building.cooling_consumption[cte.YEAR][0])
|
||||
self.assertLess(0, building.domestic_hot_water_consumption[cte.YEAR][0])
|
||||
self.assertLess(0, building.onsite_electrical_production[cte.YEAR][0])
|
||||
|
|
|
@ -59,8 +59,8 @@ class TestUsageFactory(TestCase):
|
|||
self.assertIsNone(building.terrains, 'building terrains is not none')
|
||||
self.assertIsNotNone(building.year_of_construction, 'building year_of_construction is none')
|
||||
self.assertIsNotNone(building.function, 'building function is none')
|
||||
self.assertEqual(len(building.heating), 0, 'building heating is not none')
|
||||
self.assertEqual(len(building.cooling), 0, 'building cooling is not none')
|
||||
self.assertEqual(len(building.heating_demand), 0, 'building heating is not none')
|
||||
self.assertEqual(len(building.cooling_demand), 0, 'building cooling is not none')
|
||||
self.assertIsNotNone(building.eave_height, 'building eave height is none')
|
||||
self.assertIsNotNone(building.roof_type, 'building roof type is none')
|
||||
self.assertIsNotNone(building.floor_area, 'building floor_area is none')
|
||||
|
|
Loading…
Reference in New Issue
Block a user