Add retrieve result test and correct lock in sqlalchemy
This commit is contained in:
parent
deb04cbe2d
commit
30908eda6d
@ -440,8 +440,7 @@ class Building(CityObject):
|
||||
"""
|
||||
results = {}
|
||||
if cte.HOUR in self.heating_demand:
|
||||
monthly_values = PeakLoads().\
|
||||
peak_loads_from_hourly(self.heating_demand[cte.HOUR])
|
||||
monthly_values = PeakLoads().peak_loads_from_hourly(self.heating_demand[cte.HOUR])
|
||||
else:
|
||||
monthly_values = PeakLoads(self).heating_peak_loads_from_methodology
|
||||
if monthly_values is None:
|
||||
|
@ -33,9 +33,7 @@ class ThermalControl:
|
||||
def _minimum_value(schedules):
|
||||
minimum = 1000
|
||||
for schedule in schedules:
|
||||
for value in schedule.values:
|
||||
if value < minimum:
|
||||
minimum = value
|
||||
minimum = min(minimum, min(schedule.values))
|
||||
return minimum
|
||||
|
||||
@property
|
||||
|
@ -63,11 +63,10 @@ class LoadsCalculation:
|
||||
:return: int
|
||||
"""
|
||||
heating_load_transmitted = 0
|
||||
for internal_zone in self._building.internal_zones:
|
||||
for thermal_zone in internal_zone.thermal_zones_from_internal_zones:
|
||||
internal_temperature = thermal_zone.thermal_control.mean_heating_set_point
|
||||
heating_load_transmitted += self._get_load_transmitted(thermal_zone, internal_temperature, ambient_temperature,
|
||||
ground_temperature)
|
||||
for thermal_zone in self._building.thermal_zones_from_internal_zones:
|
||||
internal_temperature = thermal_zone.thermal_control.mean_heating_set_point
|
||||
heating_load_transmitted += self._get_load_transmitted(thermal_zone, internal_temperature, ambient_temperature,
|
||||
ground_temperature)
|
||||
return heating_load_transmitted
|
||||
|
||||
def get_cooling_transmitted_load(self, ambient_temperature, ground_temperature):
|
||||
@ -76,11 +75,10 @@ class LoadsCalculation:
|
||||
:return: int
|
||||
"""
|
||||
cooling_load_transmitted = 0
|
||||
for internal_zone in self._building.internal_zones:
|
||||
for thermal_zone in internal_zone.thermal_zones_from_internal_zones:
|
||||
internal_temperature = thermal_zone.thermal_control.mean_cooling_set_point
|
||||
cooling_load_transmitted += self._get_load_transmitted(thermal_zone, internal_temperature, ambient_temperature,
|
||||
ground_temperature)
|
||||
for thermal_zone in self._building.thermal_zones_from_internal_zones:
|
||||
internal_temperature = thermal_zone.thermal_control.mean_cooling_set_point
|
||||
cooling_load_transmitted += self._get_load_transmitted(thermal_zone, internal_temperature, ambient_temperature,
|
||||
ground_temperature)
|
||||
return cooling_load_transmitted
|
||||
|
||||
def get_heating_ventilation_load_sensible(self, ambient_temperature):
|
||||
@ -89,10 +87,9 @@ class LoadsCalculation:
|
||||
:return: int
|
||||
"""
|
||||
heating_ventilation_load = 0
|
||||
for internal_zone in self._building.internal_zones:
|
||||
for thermal_zone in internal_zone.thermal_zones_from_internal_zones:
|
||||
internal_temperature = thermal_zone.thermal_control.mean_heating_set_point
|
||||
heating_ventilation_load += self._get_load_ventilation(thermal_zone, internal_temperature, ambient_temperature)
|
||||
for thermal_zone in self._building.thermal_zones_from_internal_zones:
|
||||
internal_temperature = thermal_zone.thermal_control.mean_heating_set_point
|
||||
heating_ventilation_load += self._get_load_ventilation(thermal_zone, internal_temperature, ambient_temperature)
|
||||
return heating_ventilation_load
|
||||
|
||||
def get_cooling_ventilation_load_sensible(self, ambient_temperature):
|
||||
@ -101,10 +98,9 @@ class LoadsCalculation:
|
||||
:return: int
|
||||
"""
|
||||
cooling_ventilation_load = 0
|
||||
for internal_zone in self._building.internal_zones:
|
||||
for thermal_zone in internal_zone.thermal_zones_from_internal_zones:
|
||||
internal_temperature = thermal_zone.thermal_control.mean_cooling_set_point
|
||||
cooling_ventilation_load += self._get_load_ventilation(thermal_zone, internal_temperature, ambient_temperature)
|
||||
for thermal_zone in self._building.thermal_zones_from_internal_zones:
|
||||
internal_temperature = thermal_zone.thermal_control.mean_cooling_set_point
|
||||
cooling_ventilation_load += self._get_load_ventilation(thermal_zone, internal_temperature, ambient_temperature)
|
||||
return cooling_ventilation_load
|
||||
|
||||
def get_internal_load_sensible(self):
|
||||
@ -115,19 +111,18 @@ class LoadsCalculation:
|
||||
cooling_load_occupancy_sensible = 0
|
||||
cooling_load_lighting = 0
|
||||
cooling_load_equipment_sensible = 0
|
||||
for internal_zone in self._building.internal_zones:
|
||||
for thermal_zone in internal_zone.thermal_zones_from_internal_zones:
|
||||
cooling_load_occupancy_sensible += (thermal_zone.occupancy.sensible_convective_internal_gain
|
||||
+ thermal_zone.occupancy.sensible_radiative_internal_gain) \
|
||||
* thermal_zone.footprint_area
|
||||
cooling_load_lighting += (
|
||||
thermal_zone.lighting.density * thermal_zone.lighting.convective_fraction + thermal_zone.lighting.density *
|
||||
thermal_zone.lighting.radiative_fraction
|
||||
) * thermal_zone.footprint_area
|
||||
cooling_load_equipment_sensible += (
|
||||
thermal_zone.appliances.density * thermal_zone.appliances.convective_fraction +
|
||||
thermal_zone.appliances.density * thermal_zone.appliances.radiative_fraction
|
||||
) * thermal_zone.footprint_area
|
||||
for thermal_zone in self._building.thermal_zones_from_internal_zones:
|
||||
cooling_load_occupancy_sensible += (thermal_zone.occupancy.sensible_convective_internal_gain
|
||||
+ thermal_zone.occupancy.sensible_radiative_internal_gain) \
|
||||
* thermal_zone.footprint_area
|
||||
cooling_load_lighting += (
|
||||
thermal_zone.lighting.density * thermal_zone.lighting.convective_fraction + thermal_zone.lighting.density *
|
||||
thermal_zone.lighting.radiative_fraction
|
||||
) * thermal_zone.footprint_area
|
||||
cooling_load_equipment_sensible += (
|
||||
thermal_zone.appliances.density * thermal_zone.appliances.convective_fraction +
|
||||
thermal_zone.appliances.density * thermal_zone.appliances.radiative_fraction
|
||||
) * thermal_zone.footprint_area
|
||||
internal_load = cooling_load_occupancy_sensible + cooling_load_lighting + cooling_load_equipment_sensible
|
||||
return internal_load
|
||||
|
||||
@ -137,12 +132,11 @@ class LoadsCalculation:
|
||||
:return: int
|
||||
"""
|
||||
cooling_load_radiation = 0
|
||||
for internal_zone in self._building.internal_zones:
|
||||
for thermal_zone in internal_zone.thermal_zones_from_internal_zones:
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
for thermal_opening in thermal_boundary.thermal_openings:
|
||||
radiation = thermal_boundary.parent_surface.global_irradiance[cte.HOUR][hour] * cte.WATTS_HOUR_TO_JULES
|
||||
cooling_load_radiation += (
|
||||
thermal_opening.area * (1 - thermal_opening.frame_ratio) * thermal_opening.g_value * radiation
|
||||
)
|
||||
for thermal_zone in self._building.thermal_zones_from_internal_zones:
|
||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
||||
for thermal_opening in thermal_boundary.thermal_openings:
|
||||
radiation = thermal_boundary.parent_surface.global_irradiance[cte.HOUR][hour] * cte.WATTS_HOUR_TO_JULES
|
||||
cooling_load_radiation += (
|
||||
thermal_opening.area * (1 - thermal_opening.frame_ratio) * thermal_opening.g_value * radiation
|
||||
)
|
||||
return cooling_load_radiation
|
||||
|
@ -54,13 +54,11 @@ class PeakLoads:
|
||||
"""
|
||||
month = 1
|
||||
peaks = [0 for _ in range(12)]
|
||||
print('hv', hourly_values)
|
||||
for i in range(0, len(hourly_values)):
|
||||
if _MONTH_STARTING_HOUR[month] <= i:
|
||||
month += 1
|
||||
if hourly_values[i] > peaks[month-1]:
|
||||
peaks[month-1] = hourly_values[i]
|
||||
print('peak', peaks)
|
||||
return peaks
|
||||
|
||||
@property
|
||||
@ -75,18 +73,15 @@ class PeakLoads:
|
||||
ambient_temperature = self._building.external_temperature[cte.HOUR]
|
||||
for month in range(0, 12):
|
||||
ground_temperature = self._building.ground_temperature[cte.MONTH]['2'][month]
|
||||
heating_ambient_temperature = 100
|
||||
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
|
||||
heating_ambient_temperature = min(ambient_temperature[start_hour:end_hour])
|
||||
loads = LoadsCalculation(self._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)
|
||||
# todo: include heating ventilation latent
|
||||
heating_load_ventilation_latent = 0
|
||||
heating_load = heating_load_transmitted + heating_load_ventilation_sensible + heating_load_ventilation_latent
|
||||
heating_load = max(heating_load, 0)
|
||||
|
Loading…
Reference in New Issue
Block a user