From c9274c47d021f8e48206e9b64458345f92e3bcf3 Mon Sep 17 00:00:00 2001 From: Nathan Moore Date: Tue, 9 Jan 2024 11:07:09 -0700 Subject: [PATCH 1/9] fix CHP model for MBLv10 --- .../model_connectors/plants/templates/HeatingPlantWithCHP.mot | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geojson_modelica_translator/model_connectors/plants/templates/HeatingPlantWithCHP.mot b/geojson_modelica_translator/model_connectors/plants/templates/HeatingPlantWithCHP.mot index 4ea0f7db2..87886685c 100644 --- a/geojson_modelica_translator/model_connectors/plants/templates/HeatingPlantWithCHP.mot +++ b/geojson_modelica_translator/model_connectors/plants/templates/HeatingPlantWithCHP.mot @@ -73,7 +73,7 @@ within {{ project_name }}.Plants; final unit="Pa") "Measured pressure difference" annotation (Placement(transformation(extent={{-160,-40},{-140,-20}}),iconTransformation(extent={{-140,-50},{-100,-10}}))); - Boiler_TParallel boiHotWat( + Boiler_TParallel_new boiHotWat( redeclare package Medium=Medium, m_flow_nominal=mBoi_flow_nominal, Q_flow_nominal=QBoi_flow_nominal, @@ -239,7 +239,7 @@ equation annotation (Line(points={{-99,-30},{-94,-30},{-94,4},{-82,4}},color={0,0,127})); connect(pumOn.y,pumHW.u) annotation (Line(points={{-59,10},{-46,10},{-46,72},{12,72},{12,54},{2,54}},color={0,0,127})); - connect(boiStaCon.y_On,heaWatPumCon.ON) + connect(on,heaWatPumCon.ON) annotation (Line(points={{-99,70.6},{-88,70.6},{-88,24},{-128,24},{-128,-23.4},{-121,-23.4}},color={255,0,255})); connect(mPum_flow.y,heaWatPumCon.masFloPum) annotation (Line(points={{-121,40},{-134,40},{-134,-25.6},{-121,-25.6}},color={0,0,127})); From dfd048471d2c9263da2cbe014d69c7322d198ce4 Mon Sep 17 00:00:00 2001 From: Nathan Moore Date: Tue, 9 Jan 2024 11:10:10 -0700 Subject: [PATCH 2/9] re-enable CHP test for a short simulation duration --- tests/model_connectors/test_chp_system.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/model_connectors/test_chp_system.py b/tests/model_connectors/test_chp_system.py index e4677bcf4..c98c632c4 100644 --- a/tests/model_connectors/test_chp_system.py +++ b/tests/model_connectors/test_chp_system.py @@ -87,13 +87,12 @@ def test_build_chp_system(self): assert (root_path / 'DistrictEnergySystem.mo').exists() @pytest.mark.simulation - @pytest.mark.skip('Connector types are incompatible. HeatingPlantwithCHP:242') def test_simulate_chp_system(self): 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=17280000, # Day 200 (in seconds) (Run in summer to keep chiller happy) - stop_time=17366400, # For 1 day duration (in seconds) - step_size=3600 # (in seconds) + start_time=0, # Day 0 (in seconds) + stop_time=9999, # For 2.78 hours (in seconds) + step_size=300 # (in seconds) ) From 70fc8bcfc743094a927b7c52428b2178aad3c8ab Mon Sep 17 00:00:00 2001 From: Nathan Moore Date: Wed, 10 Jan 2024 13:18:30 -0700 Subject: [PATCH 3/9] remove unnecessary dhCon & dhDis from templates --- .../modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX.mot | 4 ---- .../modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX.py | 2 -- .../modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX_variable.mot | 4 ---- .../modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX_variable.py | 2 -- 4 files changed, 12 deletions(-) diff --git a/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX.mot b/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX.mot index 99332cdc1..8d154a88d 100644 --- a/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX.mot +++ b/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX.mot @@ -13,10 +13,6 @@ model district epsPla=0.935, {{ data['lDis'] }}, {{ data['lCon'] }} - ), - dis( - {{ data['dhDis'] }}, - {{ data['dhCon'] }} ) ); parameter String filNam[nBui]={ diff --git a/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX.py b/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX.py index d9e0140bc..85bdd9e1c 100644 --- a/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX.py +++ b/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX.py @@ -98,8 +98,6 @@ def build_from_template(self, output_dir: Path, project_name: str) -> None: nbuildings = len(template_data['building_load_files']) template_data['lDis'] = self.build_string("lDis = {", "0.5, ", nbuildings) template_data['lCon'] = self.build_string("lCon = {", "0.5, ", nbuildings) - template_data['dhDis'] = self.build_string("dhDis = {", "0.5, ", nbuildings) - template_data['dhCon'] = self.build_string("dhCon = {", "0.6, ", nbuildings) # 6: generate the modelica files from the template self.to_modelica(output_dir=Path(scaffold.districts_path.files_dir), diff --git a/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX_variable.mot b/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX_variable.mot index 5da740d9b..6d1532a39 100644 --- a/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX_variable.mot +++ b/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX_variable.mot @@ -13,10 +13,6 @@ model district epsPla=0.935, {{ data['lDis'] }}, {{ data['lCon'] }} - ), - dis( - {{ data['dhDis'] }}, - {{ data['dhCon'] }} ) ); parameter String filNam[nBui]={ diff --git a/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX_variable.py b/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX_variable.py index fe4952680..4539e3fed 100644 --- a/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX_variable.py +++ b/geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX_variable.py @@ -92,8 +92,6 @@ def build_from_template(self, output_dir: Path, project_name: str) -> None: nbuildings = len(template_data['building_load_files']) template_data['lDis'] = self.build_string("lDis = {", "0.5, ", nbuildings) template_data['lCon'] = self.build_string("lCon = {", "0.5, ", nbuildings) - template_data['dhDis'] = self.build_string("dhDis = {", "0.5, ", nbuildings) - template_data['dhCon'] = self.build_string("dhCon = {", "0.6, ", nbuildings) # 6: generate the modelica files from the template self.to_modelica(output_dir=Path(scaffold.districts_path.files_dir), From e0fe8fb5dc2d355137e9c5be0f472c2bf51355cd Mon Sep 17 00:00:00 2001 From: Nathan Moore Date: Wed, 10 Jan 2024 13:19:10 -0700 Subject: [PATCH 4/9] use Ubuntu 20 in Dockerfile --- .../modelica/lib/runner/Dockerfile | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/geojson_modelica_translator/modelica/lib/runner/Dockerfile b/geojson_modelica_translator/modelica/lib/runner/Dockerfile index ac04cfcce..b0c34b804 100644 --- a/geojson_modelica_translator/modelica/lib/runner/Dockerfile +++ b/geojson_modelica_translator/modelica/lib/runner/Dockerfile @@ -1,5 +1,6 @@ -FROM openmodelica/openmodelica:v1.22.1-gui +FROM ubuntu:focal +# These libraries help compile and simulate separately. # libgfortran4 is needed to load FMU for FMUZoneAdapterZones1.mo RUN apt update && apt --no-install-recommends install -y \ vim \ @@ -9,6 +10,20 @@ RUN apt update && apt --no-install-recommends install -y \ cmake \ && rm -rf /var/lib/apt/lists/* +# Duplicating code from OM Dockerfile: https://github.com/OpenModelica/OpenModelicaDockerImages/blob/v1.22.1/Dockerfile +# This allows us to use a different Ubuntu version than the OM Dockerfile +# tests/GMT_Lib/test_gmt_lib_des.py fails with jammy, works with focal. +ARG VERSION=1.22.1 + +RUN export DEBIAN_FRONTEND="noninteractive" && echo "VERSION: $VERSION" && test ! -z "$VERSION" && apt-get update && apt-get upgrade -qy && apt-get dist-upgrade -qy \ + && apt-get install -qy gnupg wget ca-certificates apt-transport-https \ + && echo "deb https://build.openmodelica.org/omc/builds/linux/releases/$VERSION/ `cat /etc/lsb-release | grep CODENAME | cut -d= -f2` release" > /etc/apt/sources.list.d/openmodelica.list \ + && wget https://build.openmodelica.org/apt/openmodelica.asc -O- | apt-key add - \ + && apt-get update && apt-get upgrade && apt-get dist-upgrade \ + && apt-get install --no-install-recommends -qy omc \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + # Install MSL 4.0 RUN echo \ "updatePackageIndex(); getErrorString(); installPackage(Modelica, \"4.0.0\", exactMatch=false); getErrorString();" >> /tmp/installMSL.mos && \ From ba6caac559892b0ccaa52e97a6e31fca160a40f7 Mon Sep 17 00:00:00 2001 From: Nathan Moore Date: Wed, 10 Jan 2024 13:19:29 -0700 Subject: [PATCH 5/9] bump version of dockerfile --- geojson_modelica_translator/modelica/lib/runner/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/geojson_modelica_translator/modelica/lib/runner/README.md b/geojson_modelica_translator/modelica/lib/runner/README.md index 68fd4f0bf..21c0cf278 100644 --- a/geojson_modelica_translator/modelica/lib/runner/README.md +++ b/geojson_modelica_translator/modelica/lib/runner/README.md @@ -24,6 +24,7 @@ In GMT Runner Version 2.0.0 we detached the OM version from the GMT Runner versi | GTM Runner Version | OM Version | MSL Version | MBL Version | | ------------------ | ---------- | ----------- | ----------- | +| 2.0.1 | 1.22.1 | 4.0.0 | 10.0.0 | | 2.0.0 | 1.22.1 | 4.0.0 | 10.0.0 | | 1.22.1 | 1.22.1 | 4.0.0 | 9.1.1 | | 1.22.0 | 1.21.0 | 4.0.0 | 9.1.0 | From 031316f9ecf7bfd63c39007ed89be620756b3725 Mon Sep 17 00:00:00 2001 From: Nathan Moore Date: Wed, 10 Jan 2024 13:20:07 -0700 Subject: [PATCH 6/9] use new docker image --- geojson_modelica_translator/modelica/modelica_runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geojson_modelica_translator/modelica/modelica_runner.py b/geojson_modelica_translator/modelica/modelica_runner.py index 1b2f3fc9a..7f2464895 100644 --- a/geojson_modelica_translator/modelica/modelica_runner.py +++ b/geojson_modelica_translator/modelica/modelica_runner.py @@ -151,7 +151,7 @@ def _subprocess_call_to_docker(self, run_path: Path, action: str) -> int: os.chdir(run_path) stdout_log = open('stdout.log', 'w') model_name = run_path.parts[-1] - image_name = 'nrel/gmt-om-runner:v2.0.0' + image_name = 'nrel/gmt-om-runner:v2.0.1' mo_script = 'compile_fmu' if action == 'compile' else 'simulate' try: # create the command to call the open modelica compiler inside the docker image From ddeb985f1adce1ff5469cf2ccbe4b3a2badfd1ee Mon Sep 17 00:00:00 2001 From: Nathan Moore Date: Wed, 10 Jan 2024 13:20:29 -0700 Subject: [PATCH 7/9] re-enable gmt_lib tests now that we are using ubuntu 20 --- tests/GMT_Lib/test_gmt_lib_des.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/GMT_Lib/test_gmt_lib_des.py b/tests/GMT_Lib/test_gmt_lib_des.py index 4f2aaaf5d..2296a3c9c 100644 --- a/tests/GMT_Lib/test_gmt_lib_des.py +++ b/tests/GMT_Lib/test_gmt_lib_des.py @@ -35,7 +35,6 @@ class GmtLibDesTest(unittest.TestCase): @pytest.mark.simulation - @pytest.mark.skip('Invalid root in initialization. Skipping until LBNL helps') def test_5G_des_waste_heat_and_ghx(self): # -- Setup package_output_dir = PARENT_DIR / 'output' @@ -102,7 +101,6 @@ def test_5G_des_waste_heat_and_ghx_dymola(self): assert success is True @pytest.mark.simulation - @pytest.mark.skip('Invalid root in initialization. Skipping until LBNL helps') def test_5G_des_waste_heat_and_ghx_variable(self): # -- Setup package_output_dir = PARENT_DIR / 'output' From ab209ede9e16b618fb44280885b850744e5314ff Mon Sep 17 00:00:00 2001 From: Nathan Moore Date: Wed, 10 Jan 2024 13:20:48 -0700 Subject: [PATCH 8/9] bump to real version 0.6.0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7a7f19550..598831555 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "geojson-modelica-translator" -version = "0.6.0-a0" +version = "0.6.0" description = "Package for converting GeoJSON to Modelica models for Urban Scale Analyses." authors = ["URBANopt DES Team "] license = "BSD-4-Clause" From fdbd9b59256f1c894d8b1be2573137dcdd5cc3cd Mon Sep 17 00:00:00 2001 From: Nicholas Long Date: Thu, 11 Jan 2024 09:47:30 -0700 Subject: [PATCH 9/9] break out cert download to be a file and update readme --- .../modelica/lib/runner/Dockerfile | 14 ++++++++------ .../modelica/lib/runner/README.md | 8 +++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/geojson_modelica_translator/modelica/lib/runner/Dockerfile b/geojson_modelica_translator/modelica/lib/runner/Dockerfile index b0c34b804..881c09364 100644 --- a/geojson_modelica_translator/modelica/lib/runner/Dockerfile +++ b/geojson_modelica_translator/modelica/lib/runner/Dockerfile @@ -15,13 +15,15 @@ RUN apt update && apt --no-install-recommends install -y \ # tests/GMT_Lib/test_gmt_lib_des.py fails with jammy, works with focal. ARG VERSION=1.22.1 -RUN export DEBIAN_FRONTEND="noninteractive" && echo "VERSION: $VERSION" && test ! -z "$VERSION" && apt-get update && apt-get upgrade -qy && apt-get dist-upgrade -qy \ - && apt-get install -qy gnupg wget ca-certificates apt-transport-https \ +RUN export DEBIAN_FRONTEND="noninteractive" && echo "VERSION: $VERSION" && test ! -z "$VERSION" && apt update && apt upgrade -qy && apt dist-upgrade -qy \ + && apt install -qy gnupg wget ca-certificates apt-transport-https \ && echo "deb https://build.openmodelica.org/omc/builds/linux/releases/$VERSION/ `cat /etc/lsb-release | grep CODENAME | cut -d= -f2` release" > /etc/apt/sources.list.d/openmodelica.list \ - && wget https://build.openmodelica.org/apt/openmodelica.asc -O- | apt-key add - \ - && apt-get update && apt-get upgrade && apt-get dist-upgrade \ - && apt-get install --no-install-recommends -qy omc \ - && apt-get clean \ + && wget -q https://build.openmodelica.org/apt/openmodelica.asc \ + && apt-key add openmodelica.asc \ + && rm openmodelica.asc \ + && apt update && apt upgrade && apt dist-upgrade \ + && apt install --no-install-recommends -qy omc \ + && apt clean \ && rm -rf /var/lib/apt/lists/* # Install MSL 4.0 diff --git a/geojson_modelica_translator/modelica/lib/runner/README.md b/geojson_modelica_translator/modelica/lib/runner/README.md index 21c0cf278..c78888178 100644 --- a/geojson_modelica_translator/modelica/lib/runner/README.md +++ b/geojson_modelica_translator/modelica/lib/runner/README.md @@ -35,7 +35,8 @@ In GMT Runner Version 2.0.0 we detached the OM version from the GMT Runner versi Releasing is only available to individuals with write access to the NREL org. Unfortunately, the NREL org is still under a free plan resulting in a maximum of 3 users for the entire org, which have already been allocated. -Building for release is a bit different than development since you will need to handle multiple platforms. See +Building for release is a bit different than development since you will need to handle multiple platforms (only supporting +ARM64 and AMD64 as openmodelica does not support 32-bit [only armhf]). See [docker's multi-platform images documentation](https://docs.docker.com/build/building/multi-platform/) on how to configure. ```bash @@ -46,9 +47,10 @@ docker buildx create --use # update version of OMC and determine if the latest should be updated. Ideally, the latest should be updated # only if the new OMC release is needed to fix previous issues. -docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t nrel/gmt-om-runner:v2.0.0 --push . -docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t nrel/gmt-om-runner:latest --push . +docker buildx build --platform linux/amd64,linux/arm64 -t nrel/gmt-om-runner:v2.0.1 --push . +# Push the latest, if required +docker buildx build --platform linux/amd64,linux/arm64 -t nrel/gmt-om-runner:latest --push . ``` Sign into [Docker Hub](https://hub.docker.com/repository/docker/nrel/gmt-om-runner/general) and update the version