Skip to content

Commit

Permalink
Prep for 0.4.0 release (#506)
Browse files Browse the repository at this point in the history
* Don't crash if missing reopt data, just warn and move on

* poetry update

* update microgrid sys-params with modern opendss output

* wip compile & run with spawn & optimica

* flesh out spawn.py

* tiny typo fix of web link in docstring

* add a little to spawn.py docstring

* clarify comments in compile_fmu function

* shell function to kill container if process is interrupted

* enable simulating pre-built fmu with spawn

* wip spawn_docker.sh, still missing docker run command

* create spawn image

* update comment. maybe a line of code is not needed?

* one tiny update from os.path to pathlib

* itty bitty formatting & comment cleanup

* clean up dockerfile

* start docker-compose file

* [skip ci] wip: clean up call to spawn_docker & spawn.py

* small step forward with docker-compose file

* clean up subprocess call and add compiler parameter

* clean up dockerfile even more

* add docker run command, and modelon license env var stuff

* tiny comment change

* questions when building the spawn image

* questions when starting the spawn container

* questions about calling the image in docker-compose

* ensure valid compiler is passed to spawn.py

* new path to spawn.py inside conatiner

* functional docker-compose file

* trying to install spawn into docker image

* make the create-sys-param command slightly less brittle

* cli build-sys-param command now does not break at residential buildings

* [skip ci] replace os with pathlib in base_test_case

* fix bug where district microgrid features were not processed

* include assertion for pv on a building, not just district

* uncomment simulation commands now covered with "not simulation"

* map from ditto-reader wires to mbl wires for templates

* use appropriate mbl wires in template

* add python to spawn container, default debugging, fix path passing

* use mbl line names in the cables; add todo regarding wire mapping

* Mingzhe fixed my template

* move pytest marker definition to pyproject.toml

* delete commented code that was moved to pyproject.toml

* poetry update

* run with optimica, only works for bouncing ball right now

* old version of spawn

* update issue template

* add pyfmi

* enable successful type hinting in 3.8 & 3.9

* make some spawn.py arguments specifically not required. Add some type hints

* poetry update

* remove redundant Action trigger

* Revert "enable successful type hinting in 3.8 & 3.9"

This reverts commit a69cbb6.

* type hint for list only wants one instance of dict apparently

* positional arguments need a different way of being optional

* replace named arguments in spawn_docker.sh

* wip: clean up paths transferred to spawn.py

* crazy way of including paths in the container, but it works

* autopep8

* remove reference to arg_list which is no longer used

* add in optimica-based compilation

* rename docker hub user to nrel

* use bash when piping file

* restructure weather file download

* update lock file

* update lock file

* fix i/o error

* reenable downloading both mos and epw

* reenable downloading both mos and epw

* upgrade ci to mbl master/9.1.0

* dump stdout log to logger

* Update license secret

* remove debug logs

* Add 5g to sysparams (#469)

* fix error in schema

* small refactor before 5G addition

* add choice for 4G and 5G systems

* fix oneOf condition in json schema

* update sys-params.py to work with explicitly labeled 4gdhc systems

* update some test sys param files to explicitly label 4gdhc systems

* remove "custom" title, require "ets_model" in building_def

* remove default path elements in sys_param call

* update test sys param file

* improve schema validation failure reporting

* updating schema hierarchy and types in a few places

* more updates to test sys-param file to work with choice of system generation

* json keys are not allowed to start with a number

* loop differently now that "buildings" object itself is a list

* change expanded_path test to work when called from anywhere

* fix another test now that "buildings" is a list

* update another test sys-param file to work with new schema

* WIP: fix most sys-param tests

* Revert "improve schema validation failure reporting"

This reverts commit c212750.

* fix xpath path to parse lists correctly

* fix xpath path in test so list gets parsed correctly

* update test sys param files to work with 5g schema

* simplify get_param_by_building_id now that the param default section is not a thing

* remove duplicate spawn sys param file

* update cooling plant xpath paths to district system in sys params file

* remove newly unnecessary function parameter

* remove unnecessary if-statement level

* update jsonpath parsing now that "buildings" itself is an array

* update jsonpath in model_base for new jsonpath in district_systems

* update jsonpath in load_base for indirect params

* Revert "remove unnecessary if-statement level"

This reverts commit 47b44d7.

* update sys-param tests with new jsonpaths and new exception types

* Revert "change expanded_path test to work when called from anywhere"

This reverts commit 9bd7d70.

* change more jsonpaths away from "default"

* skip geojson validation for features with "detailed_model_filename"

* remove another instace of "custom" in hardcoded jsonpath

* change jsonpath key to indirect ets params in their py files

* remove "custom" from jsonpath in load_base

* fix jsonpaths in teaser.py

* update jsonpaths in chp.py to explicitly look at 4th gen

* update jsonpaths, make filechecks more detailed in sysparams.py

* remove default values in function call, and the test for those default values

* update dict indexing in test to get to correct value now that sys-param hierarchy has changed

* fix test json path that came in from microgrid PR

* set model_base log level to info

* autopep8

* change fourthGDHC to fourth_generation and same for fifth

* remove test that only tested default sys-param values, which no longer exist

* remove sys-param file from tests that was not being used

* require ets params for each building

* implement ets requirement in each load_connector type

* fix jsonpath for new schema hierarchy

* Revert "require ets params for each building"

This reverts commit f5cf3bc.

* Revert "implement ets requirement in each load_connector type"

This reverts commit ec36396.

* remove unused variables from spawn building template

* remove unused ets variable from teaser building template

* remove ets sys-param code that is not needed, variables removed from templates

Co-authored-by: Nicholas Long <nicholas.long@nrel.gov>
Co-authored-by: Nicholas Long <1907354+nllong@users.noreply.github.com>

* Bump mako from 1.2.1 to 1.2.2

Bumps [mako](https://github.com/sqlalchemy/mako) from 1.2.1 to 1.2.2.
- [Release notes](https://github.com/sqlalchemy/mako/releases)
- [Changelog](https://github.com/sqlalchemy/mako/blob/main/CHANGES)
- [Commits](https://github.com/sqlalchemy/mako/commits)

---
updated-dependencies:
- dependency-name: mako
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Weather file at top level (#497)

* move weather to top-level in sys-param files

* update sys-param schema to put weather at top-level

* handle new weather file location in sys-params

* update sys-param tests for new weather file location

* Update schema.json

* test with 3.10

* bump supported python version

* update lock file

* change max python version to be <3.11

* poetry update

* update poetry version used for ci

* trying not supporting 3.7 in ci

* ensure "poetry update" is run in CI

(cherry picked from commit 26bb2d5)

* only support python 3.10

* only support python 3.10 in ci

* poetry update again

* simplifying tox call in ci

* bump pre-commit isort version

* quotes around 3 in pre-commit isort command

* use officially sanctioned isort for pre-commit

* set isort configs in pyproject.toml

* poetry update

* pre-commit ran with new isort version

* another attempt at passing message to pytest in tox env

* update Actions checkout and setup-python versions

* still trying to pass messages to pytest in tox

* what are the chances this works?

* surely this does not matter, right?

* back to nearly original tox call

* what if we didn't use tox in the CI tests?

* add some commands formerly supplied by the tox env

* re-enable GMT supporting python 3.7.1

* run CI tests with python 3.7 as well as 3.10

* one more poetry update

* set min python version to 3.8

* poetry update

* Revert "poetry update"

This reverts commit e882140.

* Revert "set min python version to 3.8"

This reverts commit 2093bfb.

* add python 3.10 to list of supported versions

* only support python 3.10

* revert name of test step to Tox alone, not Test/Tox

* update dependencies with poetry

* different way of running pre-commit and building docs

* ugh, case sensitivity

* comment bits about modelon in ci for now

* maybe hacky way of selecting docs env in ci

* oops, need to be in docs folder to make docs

* support python 3.7.1

* apparently we need quotes

* undelete metadata confirming this works in python 3.7.1-3.10

* 4G or 5G timeseries in Dymola (#489)

* fix error in schema

* small refactor before 5G addition

* add choice for 4G and 5G systems

* duplicate mofile from mbl, modelica-fmt ran automatically

* use dynamic model name

* ugh, ensure model name matches file name. and a few other tweaks

* beginning to update template to match mbl9.1

* enable running multiple timeseries templates in a row for ets-buildings

* pre-commit checks

* put templates in dict instead of list

* clean up redeclare statement, consider eliminating duplicate call for filNam

* update timeseriesbuilding template to match mbl9.1

* update template annotations to work with MBLv9

* autopep8 fixing blankspaces

* remove "final" label from intermediate model

* comment out variables that are no longer hardcoded in the instance

* declare filNam in this model, not the other. Set have_hotWat = true

* add missing parameters, uncomment others, alter how filNam is called

* uncomment 2 variables, remove dangling comma

* re-map some timeseries couplings to the "old" building model

* fix oneOf condition in json schema

* undo silly change to cooling mass flow rate parameter

* WIP - specify district generation in test sys params file

* WIP - enabling time series to determine which generation model to build

* update sys-params.py to work with explicitly labeled 4gdhc systems

* update some test sys param files to explicitly label 4gdhc systems

* Revert "WIP - specify district generation in test sys params file"

This reverts commit 1c4830d.

* remove "custom" title, require "ets_model" in building_def

* remove default path elements in sys_param call

* update test sys param file

* improve schema validation failure reporting

* updating schema hierarchy and types in a few places

* more updates to test sys-param file to work with choice of system generation

* json keys are not allowed to start with a number

* loop differently now that "buildings" object itself is a list

* change expanded_path test to work when called from anywhere

* fix another test now that "buildings" is a list

* update another test sys-param file to work with new schema

* WIP: fix most sys-param tests

* Revert "improve schema validation failure reporting"

This reverts commit c212750.

* fix xpath path to parse lists correctly

* fix xpath path in test so list gets parsed correctly

* update test sys param files to work with 5g schema

* simplify get_param_by_building_id now that the param default section is not a thing

* remove duplicate spawn sys param file

* update cooling plant xpath paths to district system in sys params file

* remove newly unnecessary function parameter

* remove unnecessary if-statement level

* update jsonpath parsing now that "buildings" itself is an array

* update jsonpath in model_base for new jsonpath in district_systems

* update jsonpath in load_base for indirect params

* Revert "remove unnecessary if-statement level"

This reverts commit 47b44d7.

* update sys-param tests with new jsonpaths and new exception types

* Revert "change expanded_path test to work when called from anywhere"

This reverts commit 9bd7d70.

* change more jsonpaths away from "default"

* skip geojson validation for features with "detailed_model_filename"

* remove another instace of "custom" in hardcoded jsonpath

* change jsonpath key to indirect ets params in their py files

* remove "custom" from jsonpath in load_base

* fix jsonpaths in teaser.py

* update jsonpaths in chp.py to explicitly look at 4th gen

* update jsonpaths, make filechecks more detailed in sysparams.py

* remove default values in function call, and the test for those default values

* update dict indexing in test to get to correct value now that sys-param hierarchy has changed

* fix test json path that came in from microgrid PR

* set model_base log level to info

* autopep8

* change fourthGDHC to fourth_generation and same for fifth

* remove test that only tested default sys-param values, which no longer exist

* remove sys-param file from tests that was not being used

* require ets params for each building

* implement ets requirement in each load_connector type

* fix jsonpath for new schema hierarchy

* Revert "require ets params for each building"

This reverts commit f5cf3bc.

* Revert "implement ets requirement in each load_connector type"

This reverts commit ec36396.

* remove unused variables from spawn building template

* remove unused ets variable from teaser building template

* remove ets sys-param code that is not needed, variables removed from templates

* read proper template depending on district generation in sys-param file

* autopep8

* make test_time_series pass, only works for 4G models currently

* slightly different way of handling fith and fourth gen districts

* fixing whatever was broken in my brain last time

* test file and sys-params for 5g time-series

* hack in some variables to enable user to choose between 4g & 5g models

* another hack to get time-series to generate both 4g and 5g models

* handling 4g & 5g formatting of timeseries_instance file

* ugly handling of district template data in model_base

* update 5g sys-params with new weather file location

* restore timeseries load data to 4g model after I mistakenly removed it

* add displayUnit tags to a few district template lines

* improve 5g building model descriptive text

* default 5g building to not have district service water

* add missing connect statements

* add minimum value to delTAirHea and delTAirCoo so they are never zero

* jinja logic in a few instance templates

* add 5G district template to skipped list in modelica formatter

* update one sys-param value in 5G test file

* wip: starting to modify district.py to handle 5G district templates

* 5G district template

* pretty sure that semicolon does not belong there

* remove datDes annotation, move comment characters

* fix comment on coupling templates to refer to correct model

* new 5g coupling templates

* fix comment in wind turbines code

* add line to handle 5G couplings

* update call to coupling class in 5G test with district type

* new dir for 5G couplings

* update coupling code to look for 5G couplings

* remove coupling from the wrong dir

* update test_5G file to look for 5G coupling templates

* update dependencies with poetry

* removing a few more ets references in 5G templates

* remove outdated way of looking up 5G templates

* update 5G heated water stub definition template

* oof. isort has opinions and it makes pre-commit sad

* only use ambient netwoork coupling template

* create new ambient water network stub

* minor formatting of 5G district template

* update 5g test to work with ambient network stub

* new ambient temp network stub instance

* couplings are looking better!

* templatizing 5g connection diagram lines

* clean up some leftover code from earlier exploration

* slightly less amateur way of looking in a dict

* more amateurish dict lookups removed

* remove unnecessary 5G code from 4G network stub templates, and templatize cooling temp

* remove comment about 5G test that has been addressed

* change initial values in model so heat pump does not spaz out

* slightly more realistic value for cooling water temp in 5G system

* increase temp of 5G cooling supply water

* remove comments, clean up formatting in AmbientStub definition

* increase cold water temp by 1 degree for 5G loop

* update coupling to connect cool to cool instead of hot to cool

* warm up 5G cool water temp to something more like ambient

* finish coupling cool to cool. oops.

* update lock file

* remove abandoned code for 5G district choice

* change BuildingTimeSeries model name to TimeSeriesBuilding to match filename

Co-authored-by: Nicholas Long <nicholas.long@nrel.gov>
Co-authored-by: Nicholas Long <1907354+nllong@users.noreply.github.com>

* Prep 0.4.0 release (#505)

* bump version to 0.4.0

* initial commit for automated release note config file

* add dependabot to list of authors excluded from automated release notes

* add `dependencies` to list of excluded release labels

* update changelog with copy of GH automated output

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Nicholas Long <nicholas.long@nrel.gov>
Co-authored-by: Nicholas Long <1907354+nllong@users.noreply.github.com>
Co-authored-by: amyeallen1 <amy.allen@colorado.edu>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
5 people authored Nov 4, 2022
1 parent 6fef26d commit 77464e3
Show file tree
Hide file tree
Showing 110 changed files with 3,868 additions and 3,560 deletions.
7 changes: 4 additions & 3 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<!--If appropriate, fill in the versions of the dependencies that may be causing the issue.-->

Modelica Buildings Library: `9.0.0 or GithubBranch/SHA (e.g., issue2204_gmt_mbl /SHA_XYZ)`
TEASER: `URBANopt/0.6.9`
Python: `3.7.9`
Modelica Buildings Library: `9.1.0 or GitHubBranch/SHA (e.g., issue2204_gmt_mbl /SHA_XYZ)`
Modelica Standard Library: `4.0`
TEASER: `0.7.5`
Python: `3.9.13`
25 changes: 25 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuration-options

changelog:
exclude:
labels:
- ignore-for-release
- DO NOT MERGE
- invalid
- dependencies
authors:
- octocat
- dependabot
categories:
- title: Breaking Changes 🛠
labels:
- Semver-Major
- breaking-change
- title: Exciting New Features 🎉
labels:
- Semver-Minor
- enhancement
- Feature
- title: Other Changes
labels:
- "*"
66 changes: 41 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: CI

on:
pull_request:
push:
# re-enable all branches until we start simulating again.
# branches:
Expand All @@ -23,19 +22,19 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: [3.9, 3.7]
python-version: ["3.7.1", "3.10"]
test_env: [python, precommit, docs]
mbl_branch: [v9.0.0]
mbl_branch: [master]
include:
- os: ubuntu-latest
test_env: python
mbl_branch: v9.0.0
mbl_branch: master
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
-
name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
-
Expand All @@ -46,14 +45,23 @@ jobs:
docker-compose --version
-
name: Install and configure Poetry
uses: snok/install-poetry@v1
uses: abatilo/actions-poetry@v2
with:
version: 1.1.13
poetry-version: 1.2.2
-
name: Run Poetry install
name: Install dependencies with Poetry
run: |
poetry --version
poetry install
poetry update
# -
# name: Save Optimica license to file
# if: matrix.os == 'ubuntu-latest'
# shell: bash
# run: |
# mkdir -p /home/runner/modelon
# echo "#Please do not delete this comment line." > /home/runner/modelon/license.lic
# echo "${{ secrets.MODELON_LICENSE_FILE }}" >> /home/runner/modelon/license.lic
-
name: Install modelicafmt
run: |
Expand Down Expand Up @@ -83,31 +91,39 @@ jobs:
echo "Git branch is $(git branch)"
# export MODELICAPATH for subsequent steps
echo "MODELICAPATH=${MODELICAPATH}" >> $GITHUB_ENV
# #Don't build the container anymore, just have it pull from docker hub.
# -
# name: Build Spawn Modelica Docker Container
# env:
# MODELON_MAC_ADDRESS: ${{ secrets.MODELON_MAC_ADDRESS }}
# run: |
# cd geojson_modelica_translator/modelica/lib/runner
# docker-compose build
-
name: Tox ${{ matrix.test_env }}
name: Run PyTest
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
# MODELON_MAC_ADDRESS: ${{ secrets.MODELON_MAC_ADDRESS }}
# MODELON_LICENSE_PATH: /home/runner/modelon
run: |
if [ '${{ matrix.test_env }}' == 'python' ]; then
# !! Ugh, this is ugly but necessary (poetry + tox were not passing our args correctly to pytest)
if [ '${{ matrix.os }}' == 'windows-latest' ]; then
# for windows, skip python tests that require simulation (currently broken)
poetry run tox -e ${{ matrix.test_env }} -- -m 'not simulation' ./tests
elif [ '${{ matrix.mbl_branch }}' == 'v9.0.0' ]; then
# we can no longer run any msl v4 simulations with JModelica
poetry run tox -e ${{ matrix.test_env }} -- -m 'not simulation' ./tests
else
# we can no longer run any msl v4 simulations with JModelica
poetry run tox -e ${{ matrix.test_env }} -- -m 'not simulation' ./tests
fi
else
poetry run tox -e ${{ matrix.test_env }}
poetry run pytest --doctest-modules -v --cov-report term-missing --cov . -m 'not simulation and not compilation' ./tests
fi
- name: Run pre-commit
uses: pre-commit/action@v3.0.0
with:
extra_args: --all-files
- name: Build docs
run: |
if [ '${{ matrix.test_env }}' == 'docs' ]; then
cd docs
poetry run make html
fi
-
name: Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
if: ${{ matrix.os == 'ubuntu-latest' && matrix.test_env == 'python' && matrix.mbl_branch == 'v9.0.0' }}
if: ${{ matrix.os == 'ubuntu-latest' && matrix.test_env == 'python' && matrix.mbl_branch == 'master' }}
run: |
poetry run coveralls
-
Expand All @@ -116,8 +132,8 @@ jobs:
run: |
echo "Maybe these logs will help?"
ls -alt $GITHUB_WORKSPACE
echo "============================================ stdout.log ========================================="
find $GITHUB_WORKSPACE -type f -name 'stdout.log' -print | while read filename; do
echo "============================================ stdout.log ========================================="
echo "$filename"
cat "$filename"
done
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ repos:
- id: mixed-line-ending
- id: pretty-format-json
args: ['--autofix', '--no-sort-keys']
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.4
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args: ['-m 3'] # vertical hanging
name: isort (python)
- repo: local
hooks:
- id: modelica-fmt
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
Change Log
==========

Version 0.4.0
-------------
As of version 0.4.0 changes will be published using Github automated formatting at the release itself. Those changes are copied here.

Exciting New Features 🎉
* Redeclare the teaser model to use buildings.media.air medium
* Fmu runner
* Spawn docker named args
* Compile & run with spawn & optimica
* Microgrid lines
* Add 5g to sysparams
* Weather file at top level
* Test with 3.10
* 4G or 5G timeseries in Dymola
Other Changes
* Breakout run in docker command
* Better error message if modelica timeseries files from sdk are not found
* Break out build and simulate tests
* Use mblv9
* Point tests to latest mbl release
* Cli less brittle
* Run compilation tasks on CI using spawn Modelica and optimica
* Update schema.json

Version 0.3.0
-------------
* Use MBL v9 (current master branch) for all models. Note that JModelica no longer works with this version. User must now use either Dymola or Optimica. A new solution is forthcoming.
Expand Down
14 changes: 14 additions & 0 deletions compiling_with_spawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Examples to setup Spawn in GMT

## Installing Spawn in a container

`https://github.com/NREL/MegaBOP/blob/main/main/Dockerfile#L16-L22`

## Compiling a model

```spawn modelica --create-fmu mixed_loads.Districts.DistrictEnergySystem --jmodelica --modelica-path /home/kbenne/Desktop/modelica/mixed_loads /home/kbenne/Development/modelica-buildings/Buildings/```

- Note that both the MBL and the model folder are passed (with a space) to the `--modelica-path` parameter.
- Note that the MBL path includes `Buildings/` at the end, in addition to the path used in MODELICAPATH elsewhere in the GMT.

https://github.com/urbanopt/docker-spawn-modelica#running-the-examples
20 changes: 13 additions & 7 deletions geojson_modelica_translator/geojson/urbanopt_geojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from pathlib import Path

import geojson

from geojson_modelica_translator.geojson.schemas import Schemas

_log = logging.getLogger(__name__)
Expand Down Expand Up @@ -93,13 +94,18 @@ def __init__(self, filename, building_ids=None):
self.buildings = []
for feature in self.data.features:
if feature["properties"]["type"] == "Building":
building = UrbanOptLoad(feature)
if not building_ids or building.id in building_ids:
errors = self.schemas.validate("building", building.feature.properties)
if errors:
building_errors[building.id] = errors
else:
self.buildings.append(building)
# Don't validate features with 'detailed_model_filename' in the building properties
# Buildings defined by an osm don't have all keys in geojson, they'll always fail validation
if "detailed_model_filename" in feature["properties"]:
continue
else:
building = UrbanOptLoad(feature)
if not building_ids or building.id in building_ids:
errors = self.schemas.validate("building", building.feature.properties)
if errors:
building_errors[building.id] = errors
else:
self.buildings.append(building)

if building_errors:
formatted_errors = ''
Expand Down
2 changes: 1 addition & 1 deletion geojson_modelica_translator/geojson_modelica_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def __init__(
self._system_parameters = SystemParameters(sys_params_filepath)

geojson_ids = self._system_parameters.get_default(
'$.buildings.custom[*].geojson_id',
'$.buildings.[*].geojson_id',
[]
)
self._geojson = UrbanOptGeoJson(geojson_filepath, geojson_ids)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// TimeSeries 5G Component Definitions
// TODO: the components below need to be fixed!
parameter Modelica.Units.SI.MassFlowRate mDis_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.bui.mHeaWat_flow_nominal*{{ globals.delHeaWatTemBui }}/{{ globals.delHeaWatTemDis }}
"Nominal mass flow rate of primary (district) district heating side";
parameter Modelica.Units.SI.MassFlowRate mBui_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.bui.mHeaWat_flow_nominal
"Nominal mass flow rate of secondary (building) district heating side";
parameter Modelica.Units.SI.HeatFlowRate Q_flow_nominal_{{ coupling.id }}=({{ coupling.load.id }}.bui.QHea_flow_nominal);
// Modelica.Fluid.Sources.FixedBoundary pressure_source_{{ coupling.id }}(
// redeclare package Medium={{ globals.medium_w }},
// use_T=false,
// nPorts=1)
// "Pressure source"
// annotation (Placement({{ diagram.transformation.pressure_source.fixed_boundary }}));
Modelica.Blocks.Sources.RealExpression secMasFloRat_{{ coupling.id }}(
// TODO: avoid reaching into other coupling!
// Removed the unexplained *5/7.5, and added a multiplier of 15, to have a flow rate closer to the datDes nominal value
y=15*mDis_flow_nominal_{{ graph.couplings_by_type(coupling.load.id).network_couplings[0].id }})
"Secondary loop conditioned water flow rate."
annotation (Placement({{ diagram.transformation.sec_mas_flo_rat.real_expression }}));
// TODO: move THeaWatSet (and its connection) into a specific template file (this component does not depend on the coupling)
Modelica.Blocks.Sources.RealExpression THeaWatSet_{{ coupling.id }}(
y=273.15+{{ sys_params.building.load_model_parameters.time_series.temp_hw_supply }})
"Secondary loop (Building side) heating setpoint temperature."
annotation (Placement({{ diagram.transformation.t_hea_wat_set.real_expression }}));
Modelica.Blocks.Sources.RealExpression TCooWatSet_{{ coupling.id }}(
y=273.15+{{ sys_params.building.load_model_parameters.time_series.temp_chw_supply }})
"Secondary loop (Building side) cooling setpoint temperature."
annotation (Placement({{ diagram.transformation.t_coo_wat_set.real_expression }}));
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 5G ambient, timeseries coupling connections
connect({{ coupling.load.id }}.THeaWatSupMinSet, THeaWatSet_{{ coupling.id }}.y)
annotation ({{ diagram.line.ts_load.t_hea_wat_min_set.t_hea_wat_set.y }});
connect({{ coupling.load.id }}.THeaWatSupMaxSet, THeaWatSet_{{ coupling.id }}.y)
annotation ({{ diagram.line.ts_load.t_hea_wat_max_set.t_hea_wat_set.y }});
connect({{ coupling.load.id }}.THotWatSupSet, THeaWatSet_{{ coupling.id }}.y)
annotation ({{ diagram.line.ts_load.t_hot_wat_set.t_hea_wat_set.y }});
connect({{ coupling.load.id }}.TChiWatSupSet, THeaWatSet_{{ coupling.id }}.y)
annotation ({{ diagram.line.ts_load.t_chi_wat_set.t_hea_wat_set.y }});
connect(TCooWatSet_{{ coupling.id }}.y, {{ coupling.load.id }}.TColWat)
annotation ({{ diagram.line.t_coo_wat_set.y.ts_load.t_col_wat }});
connect(secMasFloRat_{{ coupling.id }}.y, supHeaWat.m_flow_in)
annotation ({{ diagram.line.sec_mas_flo_rat.y.sup_hea_wat.m_flow_in }});
connect(supHeaWat.ports[1], {{ coupling.load.id }}.port_aSerAmb)
annotation ({{ diagram.line.sup_hea_wat.ports.ts_load.port_a_amb }});
connect({{ coupling.load.id }}.port_bSerAmb, sinHeaWat.ports[1])
annotation ({{ diagram.line.ts_load.port_b_amb.sin_hea_wat.ports }});
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"""
from pathlib import Path

from jinja2 import Environment, FileSystemLoader, StrictUndefined, meta

from geojson_modelica_translator.jinja_filters import ALL_CUSTOM_FILTERS
from geojson_modelica_translator.model_connectors.energy_transfer_systems.energy_transfer_base import (
EnergyTransferBase
Expand All @@ -51,7 +53,6 @@
PlantBase
)
from geojson_modelica_translator.utils import simple_uuid
from jinja2 import Environment, FileSystemLoader, StrictUndefined, meta


class Coupling(object):
Expand All @@ -61,13 +62,17 @@ class Coupling(object):
_template_component_definitions = 'ComponentDefinitions.mopt'
_template_connect_statements = 'ConnectStatements.mopt'

def __init__(self, model_a, model_b):
def __init__(self, model_a, model_b, district_type=None):
model_a, model_b = self._sort_models(model_a, model_b)
self._model_a = model_a
self._model_b = model_b
self.district_type = district_type
self._template_base_name = f'{model_a.model_name}_{model_b.model_name}'

self._template_dir = Path(__file__).parent / "templates" / self._template_base_name
if self.district_type == '5G':
self._template_dir = Path(__file__).parent / "5G_templates" / self._template_base_name
else:
self._template_dir = Path(__file__).parent / "templates" / self._template_base_name
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
Expand Up @@ -7,6 +7,6 @@
// TODO: This should not be here, it is entirely plant specific and should be moved elsewhere
// but since it requires a connect statement we must put it here for now...
Modelica.Blocks.Sources.RealExpression TDisSetHeaWat_{{ coupling.id }}(
each y=273.15+{{ sys_params.district_system.default.central_heating_plant_parameters.temp_setpoint_hhw }})
each y=273.15+{{ sys_params.district_system.fourth_generation.central_heating_plant_parameters.temp_setpoint_hhw }})
"District side heating water supply temperature set point."
annotation (Placement({{ diagram.transformation.t_dis_set_hea_wat.real_expression }}));
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"Secondary loop heated water flow rate."
annotation (Placement({{ diagram.transformation.sec_mas_flo_rat.real_expression }}));
Modelica.Blocks.Sources.RealExpression TDisSetHeaWat_{{ coupling.id }}(
each y=273.15+{{ sys_params.district_system.default.central_heating_plant_parameters.temp_setpoint_hhw }})
each y=273.15+{{ sys_params.district_system.fourth_generation.central_heating_plant_parameters.temp_setpoint_hhw }})
"District side heating water supply temperature set point."
annotation (Placement({{ diagram.transformation.t_dis_set_hea_wat.real_expression }}));
Modelica.Blocks.Sources.BooleanConstant mPum_flow_{{ coupling.id }}(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// spawn, ets cold water stub connections
// time series, ets cold water stub connections
connect(TChiWatSup_{{ coupling.id }}.y,supChiWat_{{ coupling.ets.id }}.T_in)
annotation ({{ diagram.line.t_chi_wat_sup.y.sup_chi_wat.t_in }});
connect({{ coupling.load.id }}.ports_bChiWat[1],sinChiWat_{{ coupling.ets.id }}.ports[1])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// cooling indirect, timeseries coupling connections
// heating indirect, timeseries coupling connections
connect({{ coupling.load.id }}.ports_bHeaWat[1], {{ coupling.ets.id }}.port_a2)
annotation ({{ diagram.line.ts_load.ports_b_hea_wat.hea_ets.port_a2 }});
connect({{ coupling.ets.id }}.port_b2,{{ coupling.load.id }}.ports_aHeaWat[1])
Expand Down
Loading

0 comments on commit 77464e3

Please sign in to comment.