Skip to content

Commit

Permalink
Use feature ids in load names instead of simple_uuid (#652)
Browse files Browse the repository at this point in the history
* use geojson_id instead of simple_uuid in load names

* fix test now that load name has changed
  • Loading branch information
vtnate authored Sep 4, 2024
1 parent 28a458c commit b869a29
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
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):
model_name = "Spawn"

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
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):
model_name = "TimeSeries"

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
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):
model_name = "TimeSeriesMFT"

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.
Expand Down
9 changes: 5 additions & 4 deletions tests/model_connectors/test_time_series_mft_ets.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ 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(
f"{self.district._scaffold.project_name}.Districts.DistrictEnergySystem",
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
Expand All @@ -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
Expand Down

0 comments on commit b869a29

Please sign in to comment.