Skip to content

Commit

Permalink
Merge branch 'develop' into bump-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
vtnate committed Jan 9, 2025
2 parents 2665766 + 4bd7079 commit 82de8e9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 43 deletions.
16 changes: 9 additions & 7 deletions geojson_modelica_translator/geojson_modelica_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,23 @@ def _parse_couplings(geojson, sys_params, sys_param_district_type):
time_series_load = TimeSeries(sys_params, geojson_load)
# couple each time series load to distribution
all_couplings.append(
Coupling(time_series_load, distribution, district_type="fifth_generation")
Coupling(time_series_load, distribution, district_type=sys_param_district_type)
)
all_couplings.append(
Coupling(time_series_load, ambient_water_stub, district_type="fifth_generation")
Coupling(time_series_load, ambient_water_stub, district_type=sys_param_district_type)
)
all_couplings.append(
Coupling(time_series_load, design_data, district_type="fifth_generation")
Coupling(time_series_load, design_data, district_type=sys_param_district_type)
)
# couple each borefield and distribution
all_couplings.append(Coupling(distribution, borefield, district_type="fifth_generation"))
all_couplings.append(Coupling(distribution, borefield, district_type=sys_param_district_type))
# couple distribution and ground coupling
all_couplings.append(Coupling(distribution, ground_coupling, district_type="fifth_generation"))
all_couplings.append(Coupling(distribution, ground_coupling, district_type=sys_param_district_type))
# empty couple between borefield and ground
all_couplings.append(Coupling(ground_coupling, borefield, district_type="fifth_generation"))
all_couplings.append(Coupling(ambient_water_stub, ambient_water_stub, district_type="fifth_generation"))
all_couplings.append(Coupling(ground_coupling, borefield, district_type=sys_param_district_type))
all_couplings.append(
Coupling(ambient_water_stub, ambient_water_stub, district_type=sys_param_district_type)
)
else:
pass # Create waste heat components & couplings

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ def __init__(self, model_a, model_b, district_type=None):
self.district_type = district_type
self._template_base_name = f"{model_a.model_name}_{model_b.model_name}"

if self.district_type == "fifth_generation":
self._template_dir = Path(__file__).parent / "5G_templates" / self._template_base_name
else:
self._template_dir = Path(__file__).parent / "templates" / self._template_base_name
match self.district_type:
case "fifth_generation":
self._template_dir = Path(__file__).parent / "5G_templates" / self._template_base_name
case "fourth_generation" | None:
self._template_dir = Path(__file__).parent / "templates" / self._template_base_name
case _:
raise Exception(f"Invalid district type: {self.district_type}")
if not Path(self._template_dir).exists():
raise Exception(f"Invalid coupling. Missing {self._template_dir} directory.")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# :copyright (c) URBANopt, Alliance for Sustainable Energy, LLC, and other contributors.
# See also https://github.com/urbanopt/geojson-modelica-translator/blob/develop/LICENSE.md

import logging
from pathlib import Path

from geojson_modelica_translator.model_connectors.model_base import ModelBase
from geojson_modelica_translator.utils import convert_c_to_k

logger = logging.getLogger(__name__)


class LoadBase(ModelBase):
"""Base class of the load connectors."""
Expand Down Expand Up @@ -125,39 +128,26 @@ def add_building(self, urbanopt_building, mapper=None):
f"\nMissing property {ke} for building {self.building_id} in geojson feature file"
)

try:
building_floor_area_m2 = self.ft2_to_m2(urbanopt_building.feature.properties["floor_area"])
except KeyError:
building_floor_area_m2 = 0
building_floor_area_m2 = self.ft2_to_m2(
urbanopt_building.feature.properties.get("floor_area", 0)
)

try:
number_stories_above_ground = urbanopt_building.feature.properties[
"number_of_stories_above_ground"
]
except KeyError:
number_stories_above_ground = number_stories
print(
f"\nAssuming all building levels are above ground for building_id: {self.building_id}"
)
number_stories_above_ground = urbanopt_building.feature.properties.get(
"number_of_stories_above_ground", number_stories
)

try:
floor_height = urbanopt_building.feature.properties["floor_height"]
except KeyError:
floor_height = 3 # Default height in meters from sdk
print(
f"No floor_height found in geojson feature file for building {self.building_id}. "
f"Using default value of {floor_height}."
)
floor_height = urbanopt_building.feature.properties.get("floor_height", 3)

# UO SDK defaults to current year, however TEASER only supports up to Year 2015
# https://github.com/urbanopt/TEASER/blob/master/teaser/data/input/inputdata/TypeBuildingElements.json#L818
# UO SDK defaults to current year.
# TEASER supports buildings built after 2015 since v1.0.1 (https://github.com/RWTH-EBC/TEASER/releases)
# TODO: Consider a different default year now that TEASER supports buildings built after 2015
try:
year_built = urbanopt_building.feature.properties["year_built"]
if urbanopt_building.feature.properties["year_built"] > 2015:
year_built = 2015
except KeyError:
year_built = 2015
print(
logger.debug(
f"No year_built found in geojson feature file for building {self.building_id}. "
f"Using default value of {year_built}."
)
Expand All @@ -173,12 +163,10 @@ def add_building(self, urbanopt_building, mapper=None):
"year_built": year_built,
}
except UnboundLocalError:
print(
logger.warning(
f"Geojson feature file is missing data for building {self.building_id}. "
"This may be caused by referencing a detailed osm in the feature file."
)
else:
continue

else:
raise SystemExit(f"Mapper {mapper} has been used")
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ modelica-builder = "~=0.6.0"
# modelica-builder = { git = "https://github.com/urbanopt/modelica-builder.git", branch = "develop"}
pandas = "~2"
requests = "~=2.28"
teaser = "1.0.1"
teaser = "1.1.0"
# teaser = { git = "https://github.com/RWTH-EBC/TEASER.git", branch = "development" }
# myst-parser = "^4.0.0"

Expand Down

0 comments on commit 82de8e9

Please sign in to comment.