partial correction for persistence

IMPORTANT: This version neec top be checked for meb import as seems that the cooling and heating demand aren't imported properly.
This commit is contained in:
Guille Gutierrez 2023-08-28 18:34:10 +02:00
parent 2f62ce3fdb
commit cfb76a9ebd

View File

@ -6,6 +6,7 @@ Project Coder Guille Gutierrez Guillermo.GutierrezMorote@concordia.ca
""" """
import datetime import datetime
import logging
from sqlalchemy import Column, Integer, String, Sequence, ForeignKey, Float from sqlalchemy import Column, Integer, String, Sequence, ForeignKey, Float
from sqlalchemy import DateTime from sqlalchemy import DateTime
@ -51,19 +52,27 @@ class CityObject(Models):
self.roof_area = sum(roof.solid_polygon.area for roof in building.roofs) self.roof_area = sum(roof.solid_polygon.area for roof in building.roofs)
self.total_pv_area = sum(roof.solid_polygon.area * roof.solar_collectors_area_reduction_factor for roof in building.roofs) self.total_pv_area = sum(roof.solid_polygon.area * roof.solar_collectors_area_reduction_factor for roof in building.roofs)
storeys = building.storeys_above_ground storeys = building.storeys_above_ground
wall_area = 0
window_ratio = 0
try:
if storeys is None: if storeys is None:
storeys = building.max_height / building.average_storey_height storeys = building.max_height / building.average_storey_height
self.total_heating_area = building.floor_area * storeys
wall_area = 0
for wall in building.walls:
wall_area += wall.solid_polygon.area
self.wall_area = wall_area
window_ratio = 0
for internal_zone in building.internal_zones: for internal_zone in building.internal_zones:
for thermal_zone in internal_zone.thermal_zones_from_internal_zones: for thermal_zone in internal_zone.thermal_zones_from_internal_zones:
for thermal_boundary in thermal_zone.thermal_boundaries: for thermal_boundary in thermal_zone.thermal_boundaries:
window_ratio = thermal_boundary.window_ratio window_ratio = thermal_boundary.window_ratio
break break
except TypeError:
storeys = 0
logging.warning(
'building %s has no storey height so heating area, storeys and window ratio cannot be calculated',
self.name
)
self.total_heating_area = building.floor_area * storeys
for wall in building.walls:
wall_area += wall.solid_polygon.area
self.wall_area = wall_area
self.windows_area = wall_area * window_ratio self.windows_area = wall_area * window_ratio
system_name = building.energy_systems_archetype_name system_name = building.energy_systems_archetype_name
if system_name is None: if system_name is None: