Skip to content

Commit

Permalink
Release 0.5.0 (#557)
Browse files Browse the repository at this point in the history
* Add support for Python 3.11 (#518)

* adjust dependency versions to support python 3.11

* skip compilation and simulation tests in tox env

* update ci for python 3.11

* change asserts to if/raise statements in modelica_runner

* ugh, forgot to change the test when I changed the assertions

* update poetry version in ci

* `poetry update`

* specify ports for each time series building in instance template (#525)

Co-authored-by: Nicholas Long <[email protected]>

* update license language (#529)

* add max_electrical_load to building sys-param data (#530)

* add max_electrical_load to building sys-param data

* alphabetize some template sys-param entries

* Modifications for GHE  (#526)

* Add GHE properties to system parameter

* add ghe parameters

* add end of file line

* Add test

* modify schema

* additional properties

* run precommit

* add description and default

* pre-commit

* add schema changes

* edit default

---------

Co-authored-by: Nathan Moore <[email protected]>

* update dependency versions (#534)

* Removing remaining tox calls (#535)

* removing remaining tox parts

* `poetry update`

---------

Co-authored-by: Nathan Moore <[email protected]>

* pre-commit has been running on all checks already (#538)

* Add Level 1 5G DES system (#539)

* update dependency versions

* initial files added for creating 5g system from existing load files

* fix path type, ignore for now

* fix types on methods, bump to python 3.8 (#540)

* fix types on methods, bump to python 3.8

* update ci exclude

* add in directory to the mos copying

* systemparameter needs to use the same data... favor param_template over data.

* expose nBui to set correctly

* default to openmodelica and fix space check in file name

* Set SWH peak to 1/10th of space heating or min 5000W (#542)

* set swh peak to one-tenth of space heating or min 5000W

* max/min are hard

* Update geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX.py

* Update geojson_modelica_translator/modelica/GMT_Lib/DHC/DHC_5G_waste_heat_GHX.py

Co-authored-by: Nathan Moore <[email protected]>

* float precision is not needed. now using int instead

* test for new int value in shw instead of float

* update dependencies

---------

Co-authored-by: Nathan Moore <[email protected]>

* Issue511 ghe templates (#533)

* Add redeclaration of allowFlowReverseSer=true

* Inital implementation of district system template with single GHE

* Add modified GroundTemperatureResponse class to overwrite MBL

* Initial implementation of OneUTube and PartialBorefield templates

* Fix bug of inconsistent template name and Modelica class name of BuildingTimeSeries

* Update system template, removed temperature sensors

* District energy test file that has multiple buildings

* Add comment and test version control with VSCode

* Add declaration of borefield data parameters

* Add template for TwoUTubes borefield

* Remove unneeded mo files

* Modify input field names based on schema

* Change within statement

* Initial implementation of borefield.py

* Conversion of shank spacing

* Modify shank spacing conversion

* Remove unneeded mo file

* Minor changes to model_name

* Add system template for testing borefield template

* Initial implementation of borefield test

* Move ghe system parameter files to right location

* Take out SingleGHE system template for now

* Change within statement

* Initial implementation of borefield coupling

* Add code to point to BorefieldSystem.mot

* Remove duplicated test script

* Rename package

* Add {%endraw%} at the end

* Add input fields needed for the test

* Debugging changes

* Add borefield_instance.mopt

* Changes for debugging, now the test passes

* Add borehole_length to example system params file

* Debug PartialBorefield.mot, it passes check

* Change coupling definitions

* Minor changes

* Remove partial template models

* Add sample g-function and path

* Reverting 3 system params files

* pre-commit now with more modelica-fmt

* Apply uniform 5G district system template

* Remove unused GHE district template

* Fix for non-ghe 5G districts

---------

Co-authored-by: Nathan Moore <[email protected]>

* Add MOS file wrapper and size the 5G mass flow rate (#548)

* new class for reading mos file variables

* add mf sizing and expose plant mass flow variable

* fix typing warning for round

* reduce delta t to 10C

* reduce delta t to 5C

* Add OpenModelica compatibility (#516)

* updating plant components to work with OpenModelica

* add "each" to array of parameters. first pass

* remove nports count setting for OM

* bump requests version to remove RequestsDependencyWarning about charset_normalizer

* `poetry update`

* redeclare the correct building class in 5G timeseries template

* `allowFlowReversal` in timeseries_instance to make OM solver happy

* put FlowReversal only in the 5g part of TimeSeries_Instance

* lower 5G building hot water supply/return temps

* restore nports=1 for 4g timeseries buildings

* allowFlowReversal=true in heat exchanger

* add within statement at top of getPeakMassFlowRate.mo

* read getPeakMassFlowRate.mo as a template, so we can have the model name added properly

* add spaces around project_name in mft template

* add allowFlowReversal=true to all 4G timeseries buildings

* allowFlowReversal=true in network2pip_instance [skip-ci]

* set all remaining allowFlowReversal=true [ci skip]

* tell modelica formatter to ignore getPeakMassFlowRate.mo because of failures

* change getPeakMassFlowRate.mo to *.mot, reactivate modelica-fmt on it

* oops, look for new filename [ci-skip]

* remove commented code [skip ci]

* add Medium redeclaration in MFT template

* add OM files folder

* All_spawn_models

* Teaser Single worked

* add timeseries output nodes to make OM happy

* allow flow reversal in spawn building

* relax thermal zone constraint in teaser

* properly check for chp in sys param file

* fix double appending of heating plant when no chp to package.order

* pre-commit on Jiazhen's temp files for OM testing; remove some spawn-single files

* remove requirements.txt check from pre-commit, since we don't use that

* `poetry update`

* Spawn and Teaser changes

* pre-commit formatted Jiazhens modelica files

* hardcode numberofchillers=2 as a hack because OM does not do dot access

* add `allowFlowReversal=true` to spawn load instance

* hack in the hardcoded numberofchillers to make OM happy

* update 5g sys-param file to use 5g ets params

* add district 5g timeseries test

* `poetry update`

* add `.pytest_cache` to gitignore

* update mft connect statements to work in OM

* remove commented template code

* get 5g districts of multiple buildings working

* remove test models from Jiazhen

* `poetry update`

* use newer version of poetry in ci

* remove redundant `precommit` test env from CI matrix

* remind poetry that we only support python >=3.9 now

* `poetry update`

* use newest poetry patch in ci

* autopep8

---------

Co-authored-by: jiazhenling <[email protected]>

* Modify GHE params (#537)

* remove connectors from ghe params

* modify test and ghe system param file

* update ghe parameters schema

* modify ghe parameters

* modify ghe parameters

* add system parameter files for borehole test

* update example files

* update example files for model connectors

* add ets 5th gen params

* add array for ghe geometry params

* remove print statement from test

* Adds defaults and required fields for ghe_params and 5th gen ets params

---------

Co-authored-by: Nicholas Long <[email protected]>

* Fixing borefield test breaks due to schema changes (#550)

* Add redeclaration of allowFlowReverseSer=true

* Inital implementation of district system template with single GHE

* Add modified GroundTemperatureResponse class to overwrite MBL

* Initial implementation of OneUTube and PartialBorefield templates

* Fix bug of inconsistent template name and Modelica class name of BuildingTimeSeries

* Update system template, removed temperature sensors

* District energy test file that has multiple buildings

* Add comment and test version control with VSCode

* Add declaration of borefield data parameters

* Add template for TwoUTubes borefield

* Remove unneeded mo files

* Modify input field names based on schema

* Change within statement

* Initial implementation of borefield.py

* Conversion of shank spacing

* Modify shank spacing conversion

* Remove unneeded mo file

* Minor changes to model_name

* Add system template for testing borefield template

* Initial implementation of borefield test

* Move ghe system parameter files to right location

* Take out SingleGHE system template for now

* Change within statement

* Initial implementation of borefield coupling

* Add code to point to BorefieldSystem.mot

* Remove duplicated test script

* Rename package

* Add {%endraw%} at the end

* Add input fields needed for the test

* Debugging changes

* Add borefield_instance.mopt

* Changes for debugging, now the test passes

* Add borehole_length to example system params file

* Debug PartialBorefield.mot, it passes check

* Change coupling definitions

* Minor changes

* Remove partial template models

* Add sample g-function and path

* Reverting 3 system params files

* pre-commit now with more modelica-fmt

* Apply uniform 5G district system template

* Remove unused GHE district template

* Fix for non-ghe 5G districts

* Delete sys_param files not needed

* Replace Gfunction input with csv file

* Point to the right sys_param file

* Updated template to reflect schema changes

* Changes for the test to run

* Fix backslashes

* Change to adapt to recent commits

* Temporary fixes to make the test pass

* Change ghe_dir to relative path

* Use pathlib to handle ghe_dir

* Add if statement to avoid breaking other 5G tests

* Change due to schema change

* Pre-commit changes

* Fix bug

---------

Co-authored-by: Nathan Moore <[email protected]>

* Updating GHE Parameters: Modifying GHE Parameters schema and example files (#551)

* remove loads as required

* add objects for unique ghe properties

* update ghe specific schema objects

* add borehole to ghe specific properties

* update schema and example to not require autopopulated fields

* update to relative path

* update model connector examples

* Fix borefield test breaks due to the schema changes in issue #551 (#554)

* Add redeclaration of allowFlowReverseSer=true

* Inital implementation of district system template with single GHE

* Add modified GroundTemperatureResponse class to overwrite MBL

* Initial implementation of OneUTube and PartialBorefield templates

* Fix bug of inconsistent template name and Modelica class name of BuildingTimeSeries

* Update system template, removed temperature sensors

* District energy test file that has multiple buildings

* Add comment and test version control with VSCode

* Add declaration of borefield data parameters

* Add template for TwoUTubes borefield

* Remove unneeded mo files

* Modify input field names based on schema

* Change within statement

* Initial implementation of borefield.py

* Conversion of shank spacing

* Modify shank spacing conversion

* Remove unneeded mo file

* Minor changes to model_name

* Add system template for testing borefield template

* Initial implementation of borefield test

* Move ghe system parameter files to right location

* Take out SingleGHE system template for now

* Change within statement

* Initial implementation of borefield coupling

* Add code to point to BorefieldSystem.mot

* Remove duplicated test script

* Rename package

* Add {%endraw%} at the end

* Add input fields needed for the test

* Debugging changes

* Add borefield_instance.mopt

* Changes for debugging, now the test passes

* Add borehole_length to example system params file

* Debug PartialBorefield.mot, it passes check

* Change coupling definitions

* Minor changes

* Remove partial template models

* Add sample g-function and path

* Reverting 3 system params files

* pre-commit now with more modelica-fmt

* Apply uniform 5G district system template

* Remove unused GHE district template

* Fix for non-ghe 5G districts

* Delete sys_param files not needed

* Replace Gfunction input with csv file

* Point to the right sys_param file

* Updated template to reflect schema changes

* Changes for the test to run

* Fix backslashes

* Change to adapt to recent commits

* Temporary fixes to make the test pass

* Change ghe_dir to relative path

* Use pathlib to handle ghe_dir

* Add if statement to avoid breaking other 5G tests

* Change due to schema change

* Pre-commit changes

* Fix bug

* Changes due to schema change

---------

Co-authored-by: Nathan Moore <[email protected]>

---------

Co-authored-by: Jing Wang <[email protected]>
Co-authored-by: Nathan Moore <[email protected]>

* Enable compile & simulate with OpenModelica in Docker (#545)

* updating plant components to work with OpenModelica

* add "each" to array of parameters. first pass

* remove nports count setting for OM

* bump requests version to remove RequestsDependencyWarning about charset_normalizer

* `poetry update`

* redeclare the correct building class in 5G timeseries template

* `allowFlowReversal` in timeseries_instance to make OM solver happy

* put FlowReversal only in the 5g part of TimeSeries_Instance

* lower 5G building hot water supply/return temps

* restore nports=1 for 4g timeseries buildings

* allowFlowReversal=true in heat exchanger

* add within statement at top of getPeakMassFlowRate.mo

* read getPeakMassFlowRate.mo as a template, so we can have the model name added properly

* add spaces around project_name in mft template

* add allowFlowReversal=true to all 4G timeseries buildings

* allowFlowReversal=true in network2pip_instance [skip-ci]

* set all remaining allowFlowReversal=true [ci skip]

* tell modelica formatter to ignore getPeakMassFlowRate.mo because of failures

* change getPeakMassFlowRate.mo to *.mot, reactivate modelica-fmt on it

* oops, look for new filename [ci-skip]

* remove commented code [skip ci]

* add Medium redeclaration in MFT template

* add OM files folder

* All_spawn_models

* Teaser Single worked

* add timeseries output nodes to make OM happy

* allow flow reversal in spawn building

* relax thermal zone constraint in teaser

* properly check for chp in sys param file

* fix double appending of heating plant when no chp to package.order

* pre-commit on Jiazhen's temp files for OM testing; remove some spawn-single files

* remove requirements.txt check from pre-commit, since we don't use that

* `poetry update`

* Spawn and Teaser changes

* pre-commit formatted Jiazhens modelica files

* hardcode numberofchillers=2 as a hack because OM does not do dot access

* add `allowFlowReversal=true` to spawn load instance

* hack in the hardcoded numberofchillers to make OM happy

* update 5g sys-param file to use 5g ets params

* add district 5g timeseries test

* `poetry update`

* add `.pytest_cache` to gitignore

* update mft connect statements to work in OM

* remove commented template code

* get 5g districts of multiple buildings working

* remove test models from Jiazhen

* `poetry update`

* use newer version of poetry in ci

* remove redundant `precommit` test env from CI matrix

* wip: OM Docker code partial setup. Needs at least more Dockerfile work

* remind poetry that we only support python >=3.9 now

* `poetry update`

* use newest poetry patch in ci

* autopep8

* ignore typing error, and temporarily(?) remove method argument

* om docker-compose yml file

* change call from `spawn_docker.sh` to `om_docker.sh`

* OM Dockerfile, and remove old Dockerfile

* update modelica_runner for OM and remove spawn references

* update python and shell scripts to run OM in Docker container

* remove files no longer necessary

* more updates for switch from spawn to OM

* update test regarding switch from spawn to OM

* re-enable a third cli argument for om.py in the container

* handle a third argument to the cli inside the container

* clean up docstring, try a new path to om_docker.sh

* uncomment the file moving lines I commented. doh

* tell mypy to ignore a line in om.py

* run the same model we're testing for build success

* Enable tests to run in docker with omc (#552)

* Modify GHE params (#537)

* remove connectors from ghe params

* modify test and ghe system param file

* update ghe parameters schema

* modify ghe parameters

* modify ghe parameters

* add system parameter files for borehole test

* update example files

* update example files for model connectors

* add ets 5th gen params

* add array for ghe geometry params

* remove print statement from test

* Adds defaults and required fields for ghe_params and 5th gen ets params

---------

Co-authored-by: Nicholas Long <[email protected]>

* incremental updates, bouncingball should work

* refactor the run in docker command

* symlink mbl when running om.py

* update the signature of the run_in_docker command.

* mypy updates

* remove optimica vars and enable running simulations

* do not run simulations on windows

* update lock files

* update poetry, cleanup results to not include c code

* fix boreholefield build, run still fails--ignoring

* mark spawn and teaser models as failing. There are errors reported even though the mat file is created

* udpate create_mbl_mount bash function to get mbl path in a better way

* handle case where user downloads MBL and the Buildings path is one level higher

* update poetry lock

* dedent

* Dockerfile now builds image that works with ARM chips

* Update uo_des.py

---------

Co-authored-by: tanushree04 <[email protected]>
Co-authored-by: Nathan Moore <[email protected]>

---------

Co-authored-by: jiazhenling <[email protected]>
Co-authored-by: Nicholas Long <[email protected]>
Co-authored-by: tanushree04 <[email protected]>
Co-authored-by: Nicholas Long <[email protected]>

* Enhance and expand microgrid templates and code (#549)

* capacitor template from zhanwei and code to render it

* refactor to reduce line-length

* add minimal capacitor examples to microgrid test sys-param

* new test for creating a capacitor model from template

* district battery template and code

* test for building district battery from template

* generator code and template

* update microgrid test sys-param file to include building generators

* test for building a generator model

* reformat simple_gmt_base.py to shorten line length

* clarify variables in generator code

* template and code for electrical grid

* updated micrigrid example sys-param to include electrical grid params

* add test for creating grid model

* inductive load template and code

* microgrid sys-params for ac inductive loads

* test for building inductive load model

* simplify `within` statement because the models are still simple

* fix ACLine template to work with OM

* capitalize Inductive.py (and change test call to it) to make github happy

* also capitalizing Battery.py and changing the test to match

* additional parameters for capacitors so simulations succeed on OM

---------

Co-authored-by: Nicholas Long <[email protected]>

* Prepare 0.5 release (#556)

* prep release

* add changelog

---------

Co-authored-by: Nathan Moore <[email protected]>
Co-authored-by: tanushree04 <[email protected]>
Co-authored-by: Jing Wang <[email protected]>
Co-authored-by: jiazhenling <[email protected]>
  • Loading branch information
5 people authored Jun 9, 2023
1 parent 2ebf5eb commit e8d54cc
Show file tree
Hide file tree
Showing 137 changed files with 84,656 additions and 2,184 deletions.
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ source =

[report]
omit =
.tox/*
management/update_schemas.py
management/check_sys_params.py
geojson_modelica_translator/model_connectors/load_connectors/templates/RunSpawnCouplingBuilding.most
Expand Down
77 changes: 34 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,49 +21,39 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest]
python-version: ["3.8", "3.10"]
test_env: [python, precommit, docs]
os: [ubuntu-latest, windows-latest]
python-version: ["3.10", "3.11"]
test_env: [python, docs, mypy]
mbl_branch: [maint_9.1.x]
include:
- os: ubuntu-20.04
test_env: python
mbl_branch: maint_9.1.x
exclude:
# only test mypy on linux for all versions of python
- os: windows-latest
test_env: mypy
# only test docs on linux for all versions of python
- os: windows-latest
test_env: docs
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
-
name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
-
name: Display system info
- name: Display system info
run: |
python -c "import sys; print(sys.version)"
docker --version
docker-compose --version
-
name: Install and configure Poetry
- name: Install and configure Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.2.2
-
name: Install dependencies with Poetry
poetry-version: 1.4.2
- name: Install dependencies with Poetry
run: |
poetry --version
poetry install
poetry update
# -
# name: Save Optimica license to file
# if: matrix.os == 'ubuntu-20.04'
# 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
- name: Install modelicafmt
run: |
RUNNER_SYSTEM=$(python -c 'import platform; print(platform.system())')
curl -SLO "https://github.com/urbanopt/modelica-fmt/releases/download/v0.2-pr.2/modelica-fmt_0.2-pr.2_${RUNNER_SYSTEM}_x86_64.tar.gz"
Expand All @@ -74,13 +64,12 @@ jobs:
else
mv modelicafmt '/c/Program Files/'
fi
-
name: Install MBL
- name: Install MBL
env:
MATRIX_OS: ${{ matrix.os }}
MBL_BRANCH: ${{ matrix.mbl_branch }}
run: |
if [[ "${MATRIX_OS}" == 'ubuntu-20.04' ]]; then
if [[ "${MATRIX_OS}" == 'ubuntu-latest' ]]; then
MODELICAPATH='/home/runner/work/modelica-buildings'
else
echo $GITHUB_WORKSPACE
Expand All @@ -91,44 +80,46 @@ 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.
# Perhaps we want to eneable this again to build the gmt running container?
# -
# 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: Run PyTest
# docker build -t nrel/gmt-om-runner:latest .
- name: Run pytest (simulation only on linux)
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
poetry run pytest --doctest-modules -v --cov-report term-missing --cov . -m 'not simulation and not compilation' ./tests
if [ '${{ matrix.os }}' == 'windows-latest' ]; then
poetry run pytest --doctest-modules -v -m 'not simulation and not compilation' ./tests
else
poetry run pytest --doctest-modules -v --cov-report term-missing --cov . ./tests
fi
fi
- name: Run pre-commit
uses: pre-commit/[email protected]
with:
extra_args: --all-files
- name: Run mypy
run: |
if [ '${{ matrix.test_env }}' == 'mypy' ]; then
poetry run mypy --install-types --non-interactive --show-error-codes .
fi
- name: Build docs
run: |
if [ '${{ matrix.test_env }}' == 'docs' ]; then
cd docs
poetry run make html
fi
-
name: Coveralls
- name: Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ matrix.os == 'ubuntu-20.04' && matrix.test_env == 'python' && matrix.mbl_branch == 'maint_9.1.x' }}
if: ${{ matrix.os == 'ubuntu-latest' && matrix.test_env == 'python' && matrix.mbl_branch == 'maint_9.1.x' }}
run: |
poetry run coveralls
-
name: Job Failed
- name: Job Failed
if: ${{ failure() }}
run: |
echo "Maybe these logs will help?"
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
.pytest_cache
nosetests.xml
coverage.xml
*,cover
Expand Down
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ repos:
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: mixed-line-ending
- id: pretty-format-json
args: ['--autofix', '--no-sort-keys']
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
Change Log
==========

Version 0.5.0
-------------

## What's Changed
### Exciting New Features 🎉
* Python 3.11 support by @vtnate in https://github.com/urbanopt/geojson-modelica-translator/pull/518
* Add max_electrical_load to building sys-param data by @vtnate in https://github.com/urbanopt/geojson-modelica-translator/pull/530
* Modifications for GHE by @tanushree04 in https://github.com/urbanopt/geojson-modelica-translator/pull/526
* Add Level 1 - 5G DES system by @nllong in https://github.com/urbanopt/geojson-modelica-translator/pull/539
* Set SWH peak to 1/10th of space heating or min 5000W by @nllong in https://github.com/urbanopt/geojson-modelica-translator/pull/542
* Added GHE templates by @JingWang-CUB in https://github.com/urbanopt/geojson-modelica-translator/pull/533
* Add OpenModelica compatibility by @vtnate in https://github.com/urbanopt/geojson-modelica-translator/pull/516
* Modify GHE params by @tanushree04 in https://github.com/urbanopt/geojson-modelica-translator/pull/537
* Enable compile & simulate with OpenModelica in Docker by @vtnate in https://github.com/urbanopt/geojson-modelica-translator/pull/545
### Other Changes
* Specify ports for each time series building in instance template by @vtnate in https://github.com/urbanopt/geojson-modelica-translator/pull/525
* Update license language by @nllong in https://github.com/urbanopt/geojson-modelica-translator/pull/529
* Add MOS file wrapper and size the 5G mass flow rate by @nllong in https://github.com/urbanopt/geojson-modelica-translator/pull/548
* Fixing borefield test breaks due to schema changes by @JingWang-CUB in https://github.com/urbanopt/geojson-modelica-translator/pull/550
* Updating GHE Parameters: Modifying GHE Parameters schema and example files by @tanushree04 in https://github.com/urbanopt/geojson-modelica-translator/pull/551
* Enhance and expand microgrid templates and code by @vtnate in https://github.com/urbanopt/geojson-modelica-translator/pull/549

## New Contributors
* @tanushree04 made their first contribution in https://github.com/urbanopt/geojson-modelica-translator/pull/526

**Full Changelog**: https://github.com/urbanopt/geojson-modelica-translator/compare/0.4.1...v0.5.0

Version 0.4.1
-------------
## What's Changed
Expand Down
19 changes: 8 additions & 11 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,21 @@ All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions
(1) Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions
(2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the
distribution.

Neither the name of the copyright holder nor the names of its contributors may be used to endorse
(3) Neither the name of the copyright holder nor the names of its contributors may be used to endorse
or promote products derived from this software without specific prior written permission.

Redistribution of this software, without modification, must refer to the software by the same
designation. Redistribution of a modified version of this software (i) may not refer to the
modified version by the same designation, or by any confusingly similar designation, and
(ii) must refer to the underlying software originally provided by Alliance as “URBANopt”. Except
to comply with the foregoing, the term “URBANopt”, or any confusingly similar designation may
not be used to refer to any modified version of this software or any modified version of the
underlying software originally provided by Alliance without the prior written consent of Alliance.
(4) Other than as required in clauses (1) and (2), distributions in any form of modifications or
other derivative works (i) may not use the "URBANopt" trademark, or any other confusingly
similar designation without specific prior written permission from Alliance for Sustainable
Energy, LLC., and (ii) must refer to the underlying software originally provided by
Alliance as “URBANopt”.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
Expand All @@ -31,7 +29,6 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


---
This library also uses some examples and components from the Modelica Buildings Library.

Expand Down
15 changes: 11 additions & 4 deletions docs/developer_resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ Follow the instructions below in order to configure your local environment:
* Return to the GMT root directory and run :code:`poetry install`
* Test if everything is installed correctly by running :code:`poetry run pytest -m 'not compilation and not simulation'`. This will run all the unit and integration tests.
* Follow the instructions below to install pre-commit.
* To test pre-commit and building the documentation, you can run :code:`poetry run tox`
* To test pre-commit and building the documentation, you can run

.. code-block::
poetry install
poetry run pytest -m 'not compilation and not simulation' --doctest-modules -v --cov-report term-missing --cov .
The tests should all pass assuming the libraries are installed correctly on your computer. Also, there will be a set
of Modelica models that are created and persisted into the :code:`tests/output` folder and the
Expand Down Expand Up @@ -263,8 +268,12 @@ the runner to work locally.
Release Instructions
--------------------

* Bump version to <NEW_VERSION> in setup.py (use semantic versioning).
* Bump version to <NEW_VERSION> in pyproject.toml (use semantic versioning).
* Run :code:`poetry update` to ensure the lock file is up to date with the latest "pinned" dependencies.
* Run :code:`pre-commit run --all-files` to ensure code is formatted properly.
* Create a PR into develop with the updated version.
* Go to `GitHub release page <https://github.com/urbanopt/geojson-modelica-translator/tags>`_ and create a temp release tag to generate the CHANGELOG.
* Copy in the CHANGELOG entries that are relevant to the new version, commit, push, and merge after CI passes.
* Create a PR against develop into main.
* After main branch passes, merge and checkout the main branch. Build the distribution using the following code:

Expand Down Expand Up @@ -296,8 +305,6 @@ Release Instructions
./docs/publish_docs.sh
* Run :code:`git push origin <new_tag_version>`
* Go to `GitHub release page <https://github.com/urbanopt/geojson-modelica-translator/tags>`_ and convert the tag to a release.
* Copy in the CHANGELOG entries that are relevant to the new version.
* Verify new documentation on the `docs website <https://docs.urbanopt.net/geojson-modelica-translator/>`_.

Code Documentation
Expand Down
2 changes: 1 addition & 1 deletion geojson_modelica_translator/geojson/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import os

from jsonschema.validators import _LATEST_VERSION as LatestValidator
from jsonschema.validators import Draft202012Validator as LatestValidator


class Schemas(object):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// No components for borefield and ambient water stub coupling
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Borefield ambient coupling connections
connect(supHeaWat_{{ sys_params.num_buildings }}.ports[1], {{ coupling.plant.id }}.port_a)
{% raw %}annotation (Line(points={{-70,10},{-10,10}}, color={0,127,255}));
{% endraw %}connect({{ coupling.plant.id }}.port_b, sinHeaWat.ports[1])
{% raw %}annotation (Line(points={{10,10},{60,10}}, color={0,127,255}));
{% endraw %}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
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 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."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ 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)
connect(secMasFloRat_{{ coupling.id }}.y, supHeaWat_{{ sys_params.load_num }}.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)
connect(supHeaWat_{{ sys_params.load_num }}.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])
connect({{ coupling.load.id }}.port_bSerAmb, sinHeaWat.ports[{{ sys_params.load_num }}])
annotation ({{ diagram.line.ts_load.port_b_amb.sin_hea_wat.ports }});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
connect(TChWSET_{{ coupling.id }}.y,{{ coupling.ets.id }}.TSetBuiSup)
annotation ({{ diagram.line.t_ch_w_set.y.coo_ets.t_set_bui_sup }});
connect({{ coupling.load.id }}.buiMasTem.y[4],TChWSET_{{ coupling.id }}.u);
connect({{ coupling.load.id }}.realOutput,TChWSET_{{ coupling.id }}.u);
connect({{ coupling.load.id }}.ports_aChiWat[1],{{ coupling.ets.id }}.port_b2)
annotation ({{ diagram.line.ts_mft_load.ports_a_chi_wat.coo_ets.port_b2 }});
connect({{ coupling.ets.id }}.port_a2,{{ coupling.load.id }}.ports_bChiWat[1])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
connect(THWSET_{{ coupling.id }}.y,{{ coupling.ets.id }}.TSetBuiSup)
annotation ({{ diagram.line.t_hw_set.y.hea_ets.t_set_bui_sup }});
connect({{ coupling.load.id }}.buiMasTem.y[2],THWSET_{{ coupling.id }}.u);
connect({{ coupling.load.id }}.y,THWSET_{{ coupling.id }}.u);
connect({{ coupling.load.id }}.ports_aHeaWat[1],{{ coupling.ets.id }}.port_b2)
annotation ({{ diagram.line.ts_mft_load.ports_a_hea_wat.hea_ets.port_b2 }});
connect({{ coupling.load.id }}.ports_bHeaWat[1],{{ coupling.ets.id }}.port_a2)
Expand Down
12 changes: 10 additions & 2 deletions geojson_modelica_translator/model_connectors/districts/district.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def to_modelica(self):
"district_within_path": '.'.join([self._scaffold.project_name, 'Districts']),
"diagram": diagram,
"couplings": [],
"models": []
"models": [],
"is_ghe_district": self.system_parameters.get_param('$.district_system.fifth_generation.ghe_parameters')
}
common_template_params = {
'globals': {
Expand All @@ -85,11 +86,14 @@ def to_modelica(self):
},
'graph': self._coupling_graph,
'sys_params': {
'district_system': self.system_parameters.get_param('$.district_system')
'district_system': self.system_parameters.get_param('$.district_system'),
# num_buildings counts the ports required for 5G systems
"num_buildings": len(self.system_parameters.get_param('$.buildings')),
}
}

# render each coupling
load_num = 1
for coupling in self._coupling_graph.couplings:
template_context = {
'diagram': diagram.to_dict(coupling.id, is_coupling=True),
Expand All @@ -98,8 +102,12 @@ def to_modelica(self):

coupling_load = coupling.get_load()
if coupling_load is not None:
# read sys params file for the load
building_sys_params = self.system_parameters.get_param_by_building_id(coupling_load.building_id, '$')
template_context['sys_params']['building'] = building_sys_params
# Note which load is being used, so ports connect properly in couplings/5G_templates/ConnectStatements
template_context['sys_params']['load_num'] = load_num
load_num += 1

templated_result = coupling.render_templates(template_context)
district_template_params['couplings'].append({
Expand Down
Loading

0 comments on commit e8d54cc

Please sign in to comment.