Skip to content

Commit

Permalink
Merge pull request #479 from urbanopt/develop
Browse files Browse the repository at this point in the history
Prepare for 0.3.0 release
  • Loading branch information
nllong authored Jun 9, 2022
2 parents a80403e + b758641 commit 3c353a0
Show file tree
Hide file tree
Showing 97 changed files with 6,617 additions and 1,082 deletions.
50 changes: 26 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ name: CI
on:
pull_request:
push:
branches:
- 'develop'
- 'main'
# re-enable all branches until we start simulating again.
# branches:
# - 'develop'
# - 'main'

defaults:
run:
shell: bash

# Cancel existing run if a new one is started
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
# 3.9 does not work as of 2020-02-01
python-version: [3.7]
python-version: [3.9, 3.7]
test_env: [python, precommit, docs]
mbl_branch: [issue2204_gmt_mbl]
mbl_branch: [v9.0.0]
include:
- os: ubuntu-latest
python-version: 3.7
test_env: python
mbl_branch: master
- os: ubuntu-latest
python-version: 3.7
test_env: check_sys_params
mbl_branch: issue2204_gmt_mbl
mbl_branch: v9.0.0
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand All @@ -45,15 +45,15 @@ jobs:
docker --version
docker-compose --version
-
name: Set up Poetry
run: |
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
# NOTE: Poetry won't be in PATH until following steps
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
$HOME/.poetry/bin/poetry install
name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.1.13
-
name: Print Environment
run: poetry --version
name: Run Poetry install
run: |
poetry --version
poetry install
-
name: Install modelicafmt
run: |
Expand Down Expand Up @@ -93,10 +93,12 @@ jobs:
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 }}' == 'master' ]; then
poetry run tox -e ${{ matrix.test_env }} -- -m 'mbl_v9 and not msl_v4_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
poetry run tox -e ${{ matrix.test_env }} -- -m 'not mbl_v9' ./tests
# 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 }}
Expand All @@ -105,7 +107,7 @@ jobs:
name: Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
if: ${{ matrix.os == 'ubuntu-latest' && matrix.test_env == 'python' && matrix.mbl_branch == 'issue2204_gmt_mbl' }}
if: ${{ matrix.os == 'ubuntu-latest' && matrix.test_env == 'python' && matrix.mbl_branch == 'v9.0.0' }}
run: |
poetry run coveralls
-
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change Log
==========

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.
* Update unit tests to break out building the tests and running the tests.

Version 0.2.3
-------------
* Add GMT Lib methods for Level 1 translation of Modelica-templated objects (for microgrid).
Expand Down
2 changes: 1 addition & 1 deletion docs/developer_resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Coupling Component Definitions
This is the template which defines new components/variables necessary for a coupling. More specifically, these are the partial template files at model_connectors/couplings/templates/<coupling name>/ComponentDefinitions.mopt. These templates have access to:

- :code:`globals`: global variables (those defined in the district.py, such as medium_w = MediumW)
- :code:`coupling`: contains the coupling id, as well as references to the coupled models under their respective types (e.g. coupling.load.id or coupling.network.id). You should append :code:`coupling.id` to any variable identifiers to prevent name collisions. For example, instead of just writing :code:`parameter Modelica.SIunits.MassFlowRate mDis_flow_nominal` you should do :code:`parameter Modelica.SIunits.MassFlowRate mDis_flow_nominal_{{ coupling.id }}` as well as any place where you would reference that variable.
- :code:`coupling`: contains the coupling id, as well as references to the coupled models under their respective types (e.g. coupling.load.id or coupling.network.id). You should append :code:`coupling.id` to any variable identifiers to prevent name collisions. For example, instead of just writing :code:`parameter Modelica.Units.SI.MassFlowRate mDis_flow_nominal` you should do :code:`parameter Modelica.Units.SI.MassFlowRate mDis_flow_nominal_{{ coupling.id }}` as well as any place where you would reference that variable.
- :code:`graph`: an instance of the CouplingGraph class, where all couplings are located. It can provide useful methods for accessing couplings throughout the entire system. Refer to the python class to see what it can do.
- :code:`sys_params`: an object containing data from the system parameters file
- :code:`district_system`: contains the data from the district_system portion of the system parameters file
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Once the MBL is installed, then the CLI can be used to create the model with the
The resulting Modelica package will be created and can be opened in a Modelica editor. Open the :code:`package.mo` file in the root directory of the generated package. You will also need to
load the MBL into your Modelica editor.

NOTE: The developers of the GMT are currently working on updating the MBL version used. If you are also a developer and need to run the unit tests in this repo, you can instruct pytest to ignore the v8 tests with :code:`poetry run pytest -m 'not mbl_v9'`, which assumes you have the MBL version documented above. To run the MBL v9 tests, you need to checkout :code:`master` and run :code:`poetry run pytest -m mbl_v9`, however several MBL v9 components now require MSL 4.0, which doesn't work within JModelica.
The latest version of this repository uses MBL v9 (not yet released, but current master branch). This version does not support running JModelica due to the upgrade to Modelica Standard Library (MSL) version 4. For this reason, the unit tests no longer run the models; therefore, you will need to mark the pytest to not run the simulations with :code:`poetry run pytest -m 'not simulation'`.


Docker Installation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
parameter Modelica.SIunits.MassFlowRate mDis_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.disFloCoo.m_flow_nominal*{{ globals.delChiWatTemBui }}/{{ globals.delChiWatTemDis }}
parameter Modelica.Units.SI.MassFlowRate mDis_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.disFloCoo.m_flow_nominal*{{ globals.delChiWatTemBui }}/{{ globals.delChiWatTemDis }}
"Nominal mass flow rate of primary (district) district cooling side"; // TODO: verify this is ok!
parameter Modelica.SIunits.MassFlowRate mBui_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.terUni[1].mChiWat_flow_nominal
parameter Modelica.Units.SI.MassFlowRate mBui_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.terUni[1].mChiWat_flow_nominal
"Nominal mass flow rate of secondary (building) district cooling side"; // TODO: verify this is ok!
parameter Modelica.SIunits.HeatFlowRate Q_flow_nominal_{{ coupling.id }}=-1*{{ coupling.load.id }}.QHea_flow_nominal[1]; // TODO: verify this is ok!
parameter Modelica.Units.SI.HeatFlowRate Q_flow_nominal_{{ coupling.id }}=-1*{{ coupling.load.id }}.QHea_flow_nominal[1]; // TODO: verify this is ok!
Modelica.Fluid.Sources.FixedBoundary pressure_source_{{ coupling.id }}(
redeclare package Medium={{ globals.medium_w }},
use_T=false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
parameter Modelica.SIunits.MassFlowRate mDis_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.disFloHea.m_flow_nominal*{{ globals.delHeaWatTemBui }}/{{ globals.delHeaWatTemDis }}
parameter Modelica.Units.SI.MassFlowRate mDis_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.disFloHea.m_flow_nominal*{{ globals.delHeaWatTemBui }}/{{ globals.delHeaWatTemDis }}
"Nominal mass flow rate of primary (district) district heating side"; // TODO: Verify this is ok!
parameter Modelica.SIunits.MassFlowRate mBui_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.terUni[1].mHeaWat_flow_nominal
parameter Modelica.Units.SI.MassFlowRate mBui_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.terUni[1].mHeaWat_flow_nominal
"Nominal mass flow rate of secondary (building) district heating side"; // TODO: Verify this is ok!
parameter Modelica.SIunits.HeatFlowRate Q_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.QHea_flow_nominal[1]; // TODO: Verify this is ok!
parameter Modelica.Units.SI.HeatFlowRate Q_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.QHea_flow_nominal[1]; // TODO: Verify this is ok!
Modelica.Fluid.Sources.FixedBoundary pressure_source_{{ coupling.id }}(
redeclare package Medium={{ globals.medium_w }},
use_T=false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
parameter Modelica.SIunits.MassFlowRate mDis_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.disFloCoo.m_flow_nominal*{{ globals.delChiWatTemBui }}/{{ globals.delChiWatTemDis }}
parameter Modelica.Units.SI.MassFlowRate mDis_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.disFloCoo.m_flow_nominal*{{ globals.delChiWatTemBui }}/{{ globals.delChiWatTemDis }}
"Nominal mass flow rate of primary (district) district cooling side"; // TODO: verify this is ok!
parameter Modelica.SIunits.MassFlowRate mBui_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.terUni[1].mChiWat_flow_nominal
parameter Modelica.Units.SI.MassFlowRate mBui_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.terUni[1].mChiWat_flow_nominal
"Nominal mass flow rate of secondary (building) district cooling side"; // TODO: verify this is ok!
parameter Modelica.SIunits.HeatFlowRate Q_flow_nominal_{{ coupling.id }}=-1*{{ coupling.load.id }}.terUni[1].QHea_flow_nominal; // TODO: verify this is ok!
parameter Modelica.Units.SI.HeatFlowRate Q_flow_nominal_{{ coupling.id }}=-1*{{ coupling.load.id }}.terUni[1].QHea_flow_nominal; // TODO: verify this is ok!
Modelica.Fluid.Sources.FixedBoundary pressure_source_{{ coupling.id }}(
redeclare package Medium={{ globals.medium_w }},
use_T=false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
parameter Modelica.SIunits.MassFlowRate mDis_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.disFloHea.m_flow_nominal*{{ globals.delHeaWatTemBui }}/{{ globals.delHeaWatTemDis }}
parameter Modelica.Units.SI.MassFlowRate mDis_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.disFloHea.m_flow_nominal*{{ globals.delHeaWatTemBui }}/{{ globals.delHeaWatTemDis }}
"Nominal mass flow rate of primary (district) district heating side"; // TODO: Verify this is ok!
parameter Modelica.SIunits.MassFlowRate mBui_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.terUni[1].mHeaWat_flow_nominal
parameter Modelica.Units.SI.MassFlowRate mBui_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.terUni[1].mHeaWat_flow_nominal
"Nominal mass flow rate of secondary (building) district heating side"; // TODO: Verify this is ok!
parameter Modelica.SIunits.HeatFlowRate Q_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.terUni[1].QHea_flow_nominal; // TODO: Verify this is ok!
parameter Modelica.Units.SI.HeatFlowRate Q_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.terUni[1].QHea_flow_nominal; // TODO: Verify this is ok!
Modelica.Fluid.Sources.FixedBoundary pressure_source_{{ coupling.id }}(
redeclare package Medium={{ globals.medium_w }},
use_T=false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Buildings.Controls.OBC.UnitConversions.From_degC TChWSET_{{ coupling.id }}
annotation (Placement({{ diagram.transformation.t_ch_w_set.unit_converter }}));
parameter Modelica.SIunits.MassFlowRate mDis_flow_nominal_{{ coupling.id }} = {{ coupling.load.id }}.mChW_flow_nominal;
parameter Modelica.SIunits.MassFlowRate mBui_flow_nominal_{{ coupling.id }} = {{ coupling.load.id }}.mChW_flow_nominal;
parameter Modelica.SIunits.HeatFlowRate Q_flow_nominal_{{ coupling.id }} = {{ coupling.load.id }}.mChW_flow_nominal*4187*{{ globals.delChiWatTemBui }};
parameter Modelica.Units.SI.MassFlowRate mDis_flow_nominal_{{ coupling.id }} = {{ coupling.load.id }}.mChW_flow_nominal;
parameter Modelica.Units.SI.MassFlowRate mBui_flow_nominal_{{ coupling.id }} = {{ coupling.load.id }}.mChW_flow_nominal;
parameter Modelica.Units.SI.HeatFlowRate Q_flow_nominal_{{ coupling.id }} = {{ coupling.load.id }}.mChW_flow_nominal*4187*{{ globals.delChiWatTemBui }};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Buildings.Controls.OBC.UnitConversions.From_degC THWSET_{{ coupling.id }}
annotation (Placement({{ diagram.transformation.t_hw_set.unit_converter }}));
parameter Modelica.SIunits.MassFlowRate mDis_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.mHW_flow_nominal*{{ globals.delHeaWatTemBui }}/{{ globals.delHeaWatTemDis }};
parameter Modelica.SIunits.MassFlowRate mBui_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.mHW_flow_nominal;
parameter Modelica.SIunits.HeatFlowRate Q_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.mHW_flow_nominal*4187*{{ globals.delHeaWatTemBui }};
parameter Modelica.Units.SI.MassFlowRate mDis_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.mHW_flow_nominal*{{ globals.delHeaWatTemBui }}/{{ globals.delHeaWatTemDis }};
parameter Modelica.Units.SI.MassFlowRate mBui_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.mHW_flow_nominal;
parameter Modelica.Units.SI.HeatFlowRate Q_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.mHW_flow_nominal*4187*{{ globals.delHeaWatTemBui }};
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// TimeSeries + CoolingIndirect Component Definitions
parameter Modelica.SIunits.MassFlowRate mDis_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.mChiWat_flow_nominal*{{ globals.delChiWatTemBui }}/{{ globals.delChiWatTemDis }}
parameter Modelica.Units.SI.MassFlowRate mDis_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.mChiWat_flow_nominal*{{ globals.delChiWatTemBui }}/{{ globals.delChiWatTemDis }}
"Nominal mass flow rate of primary (district) district cooling side";
parameter Modelica.SIunits.MassFlowRate mBui_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.mChiWat_flow_nominal
parameter Modelica.Units.SI.MassFlowRate mBui_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.mChiWat_flow_nominal
"Nominal mass flow rate of secondary (building) district cooling side";
parameter Modelica.SIunits.HeatFlowRate Q_flow_nominal_{{ coupling.id }}=-1*({{ coupling.load.id }}.QCoo_flow_nominal);
parameter Modelica.Units.SI.HeatFlowRate Q_flow_nominal_{{ coupling.id }}=-1*({{ coupling.load.id }}.QCoo_flow_nominal);
Modelica.Fluid.Sources.FixedBoundary pressure_source_{{ coupling.id }}(
redeclare package Medium={{ globals.medium_w }},
use_T=false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// TimeSeries + HeatingIndirect Component Definitions
// TODO: the components below need to be fixed!
parameter Modelica.SIunits.MassFlowRate mDis_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.mHeaWat_flow_nominal*{{ globals.delHeaWatTemBui }}/{{ globals.delHeaWatTemDis }}
parameter Modelica.Units.SI.MassFlowRate mDis_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.mHeaWat_flow_nominal*{{ globals.delHeaWatTemBui }}/{{ globals.delHeaWatTemDis }}
"Nominal mass flow rate of primary (district) district heating side";
parameter Modelica.SIunits.MassFlowRate mBui_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.mHeaWat_flow_nominal
parameter Modelica.Units.SI.MassFlowRate mBui_flow_nominal_{{ coupling.id }}={{ coupling.load.id }}.mHeaWat_flow_nominal
"Nominal mass flow rate of secondary (building) district heating side";
parameter Modelica.SIunits.HeatFlowRate Q_flow_nominal_{{ coupling.id }}=({{ coupling.load.id }}.QHea_flow_nominal);
parameter Modelica.Units.SI.HeatFlowRate Q_flow_nominal_{{ coupling.id }}=({{ coupling.load.id }}.QHea_flow_nominal);
Modelica.Fluid.Sources.FixedBoundary pressure_source_{{ coupling.id }}(
redeclare package Medium={{ globals.medium_w }},
use_T=false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ model DistrictEnergySystem
"Load side medium";

// TODO: dehardcode? Also, add display units to the other parameters.
parameter Modelica.SIunits.TemperatureDifference delChiWatTemDis(displayUnit="degC")=7;
parameter Modelica.SIunits.TemperatureDifference delChiWatTemBui=5;
parameter Modelica.SIunits.TemperatureDifference delHeaWatTemDis=12;
parameter Modelica.SIunits.TemperatureDifference delHeaWatTemBui=5;
parameter Modelica.Units.SI.TemperatureDifference delChiWatTemDis(displayUnit="degC")=7;
parameter Modelica.Units.SI.TemperatureDifference delChiWatTemBui=5;
parameter Modelica.Units.SI.TemperatureDifference delHeaWatTemDis=12;
parameter Modelica.Units.SI.TemperatureDifference delHeaWatTemBui=5;

// Models
{% for model in models %}
Expand Down
Loading

0 comments on commit 3c353a0

Please sign in to comment.