Partial correction for peakloads
This commit is contained in:
parent
7c0e03d0e0
commit
e6486bc598
|
@ -9,8 +9,11 @@ Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concord
|
|||
import sys
|
||||
from typing import List, Union
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
from hub.hub_logger import logger
|
||||
import hub.helpers.constants as cte
|
||||
import hub.helpers.peak_loads as pl
|
||||
from hub.city_model_structure.building_demand.surface import Surface
|
||||
from hub.city_model_structure.city_object import CityObject
|
||||
from hub.city_model_structure.building_demand.household import Household
|
||||
|
@ -370,15 +373,16 @@ class Building(CityObject):
|
|||
Get heating peak load in W
|
||||
:return: dict{DataFrame(float)}
|
||||
"""
|
||||
return self._heating_peak_load
|
||||
|
||||
@heating_peak_load.setter
|
||||
def heating_peak_load(self, value):
|
||||
"""
|
||||
Set heating peak load in W
|
||||
:param value: dict{DataFrame(float)}
|
||||
"""
|
||||
self._heating_peak_load = value
|
||||
results = {}
|
||||
if self.heating[cte.HOUR] is not None:
|
||||
monthly_values = pl.peak_loads_from_hourly(self.heating[cte.HOUR][0])
|
||||
results[cte.MONTH] = pd.DataFrame(monthly_values)
|
||||
yearly_value = 0
|
||||
for month_value in monthly_values:
|
||||
if month_value >= yearly_value:
|
||||
yearly_value = month_value
|
||||
results[cte.YEAR] = yearly_value
|
||||
return results
|
||||
|
||||
@property
|
||||
def cooling_peak_load(self) -> dict:
|
||||
|
@ -386,15 +390,16 @@ class Building(CityObject):
|
|||
Get cooling peak load in W
|
||||
:return: dict{DataFrame(float)}
|
||||
"""
|
||||
return self._cooling_peak_load
|
||||
results = {}
|
||||
if self.heating[cte.HOUR] is not None:
|
||||
monthly_values = pl.peak_loads_from_hourly(self.cooling[cte.HOUR][0])
|
||||
results[cte.MONTH] = pd.DataFrame(monthly_values)
|
||||
yearly_value = 0
|
||||
for month_value in monthly_values:
|
||||
if month_value >= yearly_value:
|
||||
yearly_value = month_value
|
||||
results[cte.YEAR] = yearly_value
|
||||
|
||||
@cooling_peak_load.setter
|
||||
def cooling_peak_load(self, value):
|
||||
"""
|
||||
Set peak load in W
|
||||
:param value: dict{DataFrame(float)}
|
||||
"""
|
||||
self._cooling_peak_load = value
|
||||
|
||||
@property
|
||||
def eave_height(self):
|
||||
|
|
59
hub/helpers/peak_loads.py
Normal file
59
hub/helpers/peak_loads.py
Normal file
|
@ -0,0 +1,59 @@
|
|||
import constants as cte
|
||||
|
||||
_MONTH_STARTING_HOUR = [0, 744, 1416, 2160, 2880, 3624, 4344, 5088, 5832, 6552, 7296, 8016]
|
||||
|
||||
def peak_loads_from_hourly(hourly_values):
|
||||
month = 1
|
||||
peaks = [0 for _ in range(12)]
|
||||
for i, value in enumerate(hourly_values):
|
||||
if _MONTH_STARTING_HOUR[month] <= i:
|
||||
month += 1
|
||||
if value > peaks[month-1]:
|
||||
peaks[month-1] = value
|
||||
print(peaks)
|
||||
return peaks
|
||||
|
||||
def peak_loads_from_methodology(building):
|
||||
monthly_heating_loads = []
|
||||
monthly_cooling_loads = []
|
||||
ambient_temperature = building.external_temperature[cte.HOUR][self._weather_format]
|
||||
for month in range(0, 12):
|
||||
ground_temperature = building.ground_temperature[cte.MONTH]['2'][month]
|
||||
heating_ambient_temperature = 100
|
||||
cooling_ambient_temperature = -100
|
||||
cooling_calculation_hour = -1
|
||||
start_hour = _MONTH_STARTING_HOUR[month]
|
||||
end_hour = 8760
|
||||
if month < 11:
|
||||
end_hour = _MONTH_STARTING_HOUR[month + 1]
|
||||
for hour in range(start_hour, end_hour):
|
||||
temperature = ambient_temperature[hour]
|
||||
if temperature < heating_ambient_temperature:
|
||||
heating_ambient_temperature = temperature
|
||||
if temperature > cooling_ambient_temperature:
|
||||
cooling_ambient_temperature = temperature
|
||||
cooling_calculation_hour = hour
|
||||
|
||||
loads = LoadsCalculation(building)
|
||||
heating_load_transmitted = loads.get_heating_transmitted_load(heating_ambient_temperature, ground_temperature)
|
||||
heating_load_ventilation_sensible = loads.get_heating_ventilation_load_sensible(heating_ambient_temperature)
|
||||
heating_load_ventilation_latent = 0
|
||||
heating_load = heating_load_transmitted + heating_load_ventilation_sensible + heating_load_ventilation_latent
|
||||
|
||||
cooling_load_transmitted = loads.get_cooling_transmitted_load(cooling_ambient_temperature, ground_temperature)
|
||||
cooling_load_renovation_sensible = loads.get_cooling_ventilation_load_sensible(cooling_ambient_temperature)
|
||||
cooling_load_internal_gains_sensible = loads.get_internal_load_sensible()
|
||||
cooling_load_radiation = loads.get_radiation_load(self._irradiance_format, cooling_calculation_hour)
|
||||
cooling_load_sensible = cooling_load_transmitted + cooling_load_renovation_sensible - cooling_load_radiation \
|
||||
- cooling_load_internal_gains_sensible
|
||||
|
||||
cooling_load_latent = 0
|
||||
cooling_load = cooling_load_sensible + cooling_load_latent
|
||||
if heating_load < 0:
|
||||
heating_load = 0
|
||||
if cooling_load > 0:
|
||||
cooling_load = 0
|
||||
monthly_heating_loads.append(heating_load)
|
||||
monthly_cooling_loads.append(cooling_load)
|
||||
{'monthly heating peak load': monthly_heating_loads,
|
||||
'monthly cooling peak load': monthly_cooling_loads}
|
|
@ -1,61 +0,0 @@
|
|||
import hub.helpers.constants as cte
|
||||
from hub.imports.results.peak_calculation.loads_calculation import LoadsCalculation
|
||||
|
||||
|
||||
class PeakLoad:
|
||||
_MONTH_STARTING_HOUR = [0, 744, 1416, 2160, 2880, 3624, 4344, 5088, 5832, 6552, 7296, 8016]
|
||||
|
||||
def __init__(self, city):
|
||||
self._city = city
|
||||
self._weather_format = 'epw'
|
||||
self._irradiance_format = 'sra'
|
||||
|
||||
def enrich(self):
|
||||
for building in self._city.buildings:
|
||||
if building.heating
|
||||
|
||||
|
||||
monthly_heating_loads = []
|
||||
monthly_cooling_loads = []
|
||||
ambient_temperature = building.external_temperature[cte.HOUR][self._weather_format]
|
||||
for month in range(0, 12):
|
||||
ground_temperature = building.ground_temperature[cte.MONTH]['2'][month]
|
||||
heating_ambient_temperature = 100
|
||||
cooling_ambient_temperature = -100
|
||||
cooling_calculation_hour = -1
|
||||
start_hour = self._MONTH_STARTING_HOUR[month]
|
||||
end_hour = 8760
|
||||
if month < 11:
|
||||
end_hour = self._MONTH_STARTING_HOUR[month + 1]
|
||||
for hour in range(start_hour, end_hour):
|
||||
temperature = ambient_temperature[hour]
|
||||
if temperature < heating_ambient_temperature:
|
||||
heating_ambient_temperature = temperature
|
||||
if temperature > cooling_ambient_temperature:
|
||||
cooling_ambient_temperature = temperature
|
||||
cooling_calculation_hour = hour
|
||||
|
||||
loads = LoadsCalculation(building)
|
||||
heating_load_transmitted = loads.get_heating_transmitted_load(heating_ambient_temperature, ground_temperature)
|
||||
heating_load_ventilation_sensible = loads.get_heating_ventilation_load_sensible(heating_ambient_temperature)
|
||||
heating_load_ventilation_latent = 0
|
||||
heating_load = heating_load_transmitted + heating_load_ventilation_sensible + heating_load_ventilation_latent
|
||||
|
||||
cooling_load_transmitted = loads.get_cooling_transmitted_load(cooling_ambient_temperature, ground_temperature)
|
||||
cooling_load_renovation_sensible = loads.get_cooling_ventilation_load_sensible(cooling_ambient_temperature)
|
||||
cooling_load_internal_gains_sensible = loads.get_internal_load_sensible()
|
||||
cooling_load_radiation = loads.get_radiation_load(self._irradiance_format, cooling_calculation_hour)
|
||||
cooling_load_sensible = cooling_load_transmitted + cooling_load_renovation_sensible - cooling_load_radiation \
|
||||
- cooling_load_internal_gains_sensible
|
||||
|
||||
cooling_load_latent = 0
|
||||
cooling_load = cooling_load_sensible + cooling_load_latent
|
||||
if heating_load < 0:
|
||||
heating_load = 0
|
||||
if cooling_load > 0:
|
||||
cooling_load = 0
|
||||
monthly_heating_loads.append(heating_load)
|
||||
monthly_cooling_loads.append(cooling_load)
|
||||
building. {'monthly heating peak load': monthly_heating_loads,
|
||||
'monthly cooling peak load': monthly_cooling_loads}
|
||||
|
|
@ -43,7 +43,7 @@ class TestImports(TestCase):
|
|||
sra_path = (self._output_path / f'{self._city.name}_sra.xml').resolve()
|
||||
subprocess.run(['sra', str(sra_path)])
|
||||
ResultFactory('sra', self._city, self._output_path).enrich()
|
||||
# Check that all the buildings has radiance in the surfaces
|
||||
# Check that all the buildings have radiance in the surfaces
|
||||
for building in self._city.buildings:
|
||||
for surface in building.surfaces:
|
||||
self.assertIsNotNone(surface.global_irradiance)
|
||||
|
@ -58,7 +58,10 @@ class TestImports(TestCase):
|
|||
for building in self._city.buildings:
|
||||
insel_path = (self._output_path / f'{building.name}.insel')
|
||||
subprocess.run(['insel', str(insel_path)])
|
||||
ResultFactory('insel_monthly_energy_balance', self._city, self._output_path)
|
||||
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:
|
||||
print(building.heating)
|
||||
self.assertIsNotNone(None)
|
||||
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])
|
||||
|
|
Loading…
Reference in New Issue
Block a user