Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,561 changes: 6,561 additions & 0 deletions 2020_Advanced_Retrofit.ipynb

Large diffs are not rendered by default.

6,498 changes: 6,498 additions & 0 deletions 2020_No_Retrofit.ipynb

Large diffs are not rendered by default.

6,730 changes: 6,730 additions & 0 deletions 2020_Normal_Retrofit.ipynb

Large diffs are not rendered by default.

158 changes: 0 additions & 158 deletions classes.html

This file was deleted.

65 changes: 59 additions & 6 deletions districtgenerator/classes/datahandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from ..functions import weather_handling as weather_handling
from ..functions import path_checks as path_checks
from ..functions import calculate_holidays as calculate_holidays
from ..functions import update_surfaces as update_surfaces


RESIDENTIAL_BUILDING_TYPES = ["SFH", "TH", "MFH", "AB"]
Expand Down Expand Up @@ -153,17 +154,19 @@ def setResultPath(self, new_path=None):
new_path = path_checks.check_path(new_path)
self.resultPath = new_path

def setAdvancedModel(self, pathAdvancedModel=None):
def setAdvancedModel(self, pathAdvancedModel: str) -> None:
"""
Sets the path and loads data for advanded modelling
Sets the path and loads data for advanded modelling. This includes geometry.

Args:
new_path (str, optional): The new path to set. If not provided, the default path will be used.
pathAdvancedModel (str): The path to the advanced model JSON file that contains
further attributes about geometry in TEASER coordinates.

Returns:
None
"""
self.advancedModel = pathAdvancedModel if pathAdvancedModel is not None else None
with open(pathAdvancedModel, 'r') as f:
self.advancedModel_data = json.load(f)

def setWeatherFile(self, pathWeatherFile=None):
"""
Expand Down Expand Up @@ -1164,7 +1167,7 @@ def export_building_data(self, csv_file_path:str) -> None:
retrofit_level = building["buildingFeatures"]["retrofit"]

envelope_obj = building["envelope"]
envelope_dict = vars(self.district[i]["envelope"])
envelope_dict = vars(envelope_obj)
user_dict = vars(self.district[i]["user"])

building_dict = {
Expand Down Expand Up @@ -1212,5 +1215,55 @@ def import_building_data(self):
"""
Import building data from a csv file
"""
# TODO: Implement this function to load advanced building data
# TODO Implement this function to load advanced building data
pass


def updateGeometry(self):
"""
Update building data from the advanced model.
Updates envelope data for each building based on the advanced model data.

Update building data from the advanced model.
Updates envelope data for each building based on the advanced model data.
"""
if self.advancedModel_data is None:
print("No geometry model provided. Cannot update building data.")
return

# Update each building's envelope data
for building in self.district:
building_id = building["buildingFeatures"]["gml_id"]

# Find matching building data in advanced model
building_data = self.advancedModel_data.get(building_id)

if building_data is None:
print(f"No data found for building ID {building_id} in advanced model")
continue
free_areas, connected_areas = update_surfaces.extract_surface_areas(building_data)
window_areas = update_surfaces.extract_window_areas(free_areas, connected_areas, building)

# Calculate total window area
total_window_area = sum(window_areas.values())

# Update window areas with validation
building["envelope"].A["window"]["south"] = window_areas.get("south", building["envelope"].A["window"]["south"])
building["envelope"].A["window"]["north"] = window_areas.get("north", building["envelope"].A["window"]["north"])
building["envelope"].A["window"]["west"] = window_areas.get("west", building["envelope"].A["window"]["west"])
building["envelope"].A["window"]["east"] = window_areas.get("east", building["envelope"].A["window"]["east"])
building["envelope"].A["window"]["sum"] = total_window_area

# Calculate total internal wall area including connected walls
total_connected_wall_area = sum(connected_areas.values())
internal_wall_area = building["envelope"].A["opaque"].get("intWall", 0)
total_internal_area = internal_wall_area + total_connected_wall_area

# Update opaque areas with validation
building["envelope"].A["opaque"]["south"] = max(0, free_areas.get("south", 0))
building["envelope"].A["opaque"]["north"] = max(0, free_areas.get("north", 0))
building["envelope"].A["opaque"]["west"] = max(0, free_areas.get("west", 0))
building["envelope"].A["opaque"]["east"] = max(0, free_areas.get("east", 0))
building["envelope"].A["opaque"]["roof"] = building["envelope"].A["opaque"].get("roof", 0) # Preserve existing roof area
building["envelope"].A["opaque"]["floor"] = building["envelope"].A["opaque"].get("floor", 0) # Preserve existing floor area
building["envelope"].A["opaque"]["intWall"] = max(0, total_internal_area)
Loading