From cfe112c8b2e6091179e2f42de055205a2c308257 Mon Sep 17 00:00:00 2001 From: Nathan Moore Date: Thu, 9 Jan 2025 14:01:52 -0700 Subject: [PATCH] clean up matching district generation types (#690) --- .../geojson_modelica_translator.py | 16 +++++++++------- .../model_connectors/couplings/coupling.py | 11 +++++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/geojson_modelica_translator/geojson_modelica_translator.py b/geojson_modelica_translator/geojson_modelica_translator.py index 13338dd8d..01dcf36da 100644 --- a/geojson_modelica_translator/geojson_modelica_translator.py +++ b/geojson_modelica_translator/geojson_modelica_translator.py @@ -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 diff --git a/geojson_modelica_translator/model_connectors/couplings/coupling.py b/geojson_modelica_translator/model_connectors/couplings/coupling.py index c2e9367c1..348586b37 100644 --- a/geojson_modelica_translator/model_connectors/couplings/coupling.py +++ b/geojson_modelica_translator/model_connectors/couplings/coupling.py @@ -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.")