From b869a29677487c39c4bb685c26e0cb52402e3211 Mon Sep 17 00:00:00 2001 From: Nathan Moore Date: Wed, 4 Sep 2024 14:38:54 -0600 Subject: [PATCH] Use feature ids in load names instead of simple_uuid (#652) * use geojson_id instead of simple_uuid in load names * fix test now that load name has changed --- .../model_connectors/load_connectors/spawn.py | 4 ++-- .../model_connectors/load_connectors/teaser.py | 4 ++-- .../model_connectors/load_connectors/time_series.py | 4 ++-- .../load_connectors/time_series_mft_ets_coupling.py | 4 ++-- tests/model_connectors/test_time_series_mft_ets.py | 9 +++++---- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/geojson_modelica_translator/model_connectors/load_connectors/spawn.py b/geojson_modelica_translator/model_connectors/load_connectors/spawn.py index f0ef51ef2..8399ed190 100644 --- a/geojson_modelica_translator/model_connectors/load_connectors/spawn.py +++ b/geojson_modelica_translator/model_connectors/load_connectors/spawn.py @@ -7,7 +7,7 @@ from modelica_builder.package_parser import PackageParser from geojson_modelica_translator.model_connectors.load_connectors.load_base import LoadBase -from geojson_modelica_translator.utils import ModelicaPath, convert_c_to_k, simple_uuid +from geojson_modelica_translator.utils import ModelicaPath, convert_c_to_k class Spawn(LoadBase): @@ -15,7 +15,7 @@ class Spawn(LoadBase): def __init__(self, system_parameters, geojson_load): super().__init__(system_parameters, geojson_load) - self.id = "SpawnLoad_" + simple_uuid() + self.id = f"SpawnLoad_{self.building_name}" def to_modelica(self, scaffold, keep_original_models=False): """Create spawn models based on the data in the buildings and geojsons diff --git a/geojson_modelica_translator/model_connectors/load_connectors/teaser.py b/geojson_modelica_translator/model_connectors/load_connectors/teaser.py index 7aa699d05..30e2ecffd 100644 --- a/geojson_modelica_translator/model_connectors/load_connectors/teaser.py +++ b/geojson_modelica_translator/model_connectors/load_connectors/teaser.py @@ -14,7 +14,7 @@ from teaser.project import Project from geojson_modelica_translator.model_connectors.load_connectors.load_base import LoadBase -from geojson_modelica_translator.utils import ModelicaPath, convert_c_to_k, copytree, simple_uuid +from geojson_modelica_translator.utils import ModelicaPath, convert_c_to_k, copytree class Teaser(LoadBase): @@ -25,7 +25,7 @@ class Teaser(LoadBase): def __init__(self, system_parameters, geojson_load): super().__init__(system_parameters, geojson_load) - self.id = "TeaserLoad_" + simple_uuid() + self.id = f"TeaserLoad_{self.building_name}" def lookup_building_type(self, building_type): """Look up the building type from the Enumerations in the building_properties.json schema. TEASER diff --git a/geojson_modelica_translator/model_connectors/load_connectors/time_series.py b/geojson_modelica_translator/model_connectors/load_connectors/time_series.py index e2b82faa3..a998f1d3c 100644 --- a/geojson_modelica_translator/model_connectors/load_connectors/time_series.py +++ b/geojson_modelica_translator/model_connectors/load_connectors/time_series.py @@ -7,7 +7,7 @@ from modelica_builder.package_parser import PackageParser from geojson_modelica_translator.model_connectors.load_connectors.load_base import LoadBase -from geojson_modelica_translator.utils import ModelicaPath, convert_c_to_k, simple_uuid +from geojson_modelica_translator.utils import ModelicaPath, convert_c_to_k class TimeSeries(LoadBase): @@ -15,7 +15,7 @@ class TimeSeries(LoadBase): def __init__(self, system_parameters, geojson_load): super().__init__(system_parameters, geojson_load) - self.id = "TimeSerLoa_" + simple_uuid() + self.id = f"TimeSerLoa_{self.building_name}" def to_modelica(self, scaffold): """Create timeSeries models based on the data in the buildings and geojsons diff --git a/geojson_modelica_translator/model_connectors/load_connectors/time_series_mft_ets_coupling.py b/geojson_modelica_translator/model_connectors/load_connectors/time_series_mft_ets_coupling.py index 89af756fe..74ced0a12 100644 --- a/geojson_modelica_translator/model_connectors/load_connectors/time_series_mft_ets_coupling.py +++ b/geojson_modelica_translator/model_connectors/load_connectors/time_series_mft_ets_coupling.py @@ -8,7 +8,7 @@ from modelica_builder.package_parser import PackageParser from geojson_modelica_translator.model_connectors.load_connectors.load_base import LoadBase -from geojson_modelica_translator.utils import ModelicaPath, mbl_version, simple_uuid +from geojson_modelica_translator.utils import ModelicaPath, mbl_version class TimeSeriesMFT(LoadBase): @@ -16,7 +16,7 @@ class TimeSeriesMFT(LoadBase): def __init__(self, system_parameters, geojson_load): super().__init__(system_parameters, geojson_load) - self.id = "TimeSerMFTLoa_" + simple_uuid() + self.id = f"TimeSerMFTLoa_{self.building_name}" # Note that the order of the required MO files is important as it will be the order that # the "package.order" will be in. diff --git a/tests/model_connectors/test_time_series_mft_ets.py b/tests/model_connectors/test_time_series_mft_ets.py index 8b81d8535..67db88a67 100644 --- a/tests/model_connectors/test_time_series_mft_ets.py +++ b/tests/model_connectors/test_time_series_mft_ets.py @@ -75,9 +75,9 @@ def test_build_district_system(self): def test_mft_time_series_to_modelica_and_run(self): root_path = Path(self.district._scaffold.districts_path.files_dir).resolve() mo_file_name = Path(root_path) / "DistrictEnergySystem.mo" - # set the run time to 31536000 (full year in seconds) mofile = Model(mo_file_name) - mofile.update_model_annotation({"experiment": {"StopTime": 31536000}}) + one_year_in_seconds = 31536000 # 1 year in seconds + mofile.update_model_annotation({"experiment": {"StopTime": one_year_in_seconds}}) mofile.save() self.run_and_assert_in_docker( @@ -85,7 +85,7 @@ def test_mft_time_series_to_modelica_and_run(self): file_to_load=self.district._scaffold.package_path, run_path=self.district._scaffold.project_path, start_time=0, - stop_time=31536000, + stop_time=one_year_in_seconds, ) # Check the results @@ -101,7 +101,8 @@ def test_mft_time_series_to_modelica_and_run(self): coolflow_var = None heatflow_var = None for var in mat_results.varNames(): - m = re.match("TimeSerMFTLoa_(.{8})", var) + # search for 25 characters because that is the length of the id for the test load + m = re.match("TimeSerMFTLoa_(.{25})", var) if m: timeseries_load_var = m[1] continue