Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to MSL 4.0.0 #540

Merged
merged 11 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 22 additions & 42 deletions .github/workflows/build_run_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ on: [push]
jobs:
test_modelica_build:
container:
image: openmodelica/openmodelica:v1.21.0-ompython
image: openmodelica/openmodelica:v1.23.1-ompython
name: Test Modelica Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
os: [ubuntu-24.04]
steps:
- uses: actions/checkout@v3
- name: Compile models
run: |
mkdir build
cd build
echo "installPackage(Modelica, \"3.2.3+maint.om\", exactMatch=true)" >> install.mos
echo "installPackage(Modelica, \"4.0.0\", exactMatch=true)" >> install.mos
ln -s ${GITHUB_WORKSPACE}/power_balance/models/*.mo .
omc install.mos
omc -s $(ls *.mo) Modelica +i=Tokamak.Interdependencies
Expand All @@ -31,20 +31,17 @@ jobs:
test_module_build:
name: Test Module Build (Python${{ matrix.python-version }} ${{ matrix.os }})
runs-on: ${{ matrix.os }}
container:
image: openmodelica/openmodelica:v1.23.1-ompython
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
python-version: [ '3.11', '3.9', '3.10' ]
os: [ubuntu-24.04]
python-version: [ '3.11', '3.10', '3.12' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install Poetry
run: python -m pip install poetry
run: python3 -m pip install poetry
- name: Build Module
run: |
poetry install
Expand All @@ -58,13 +55,13 @@ jobs:
retention-days: 1
model_run_om:
container:
image: openmodelica/openmodelica:v1.21.0-ompython
image: openmodelica/openmodelica:v1.23.1-ompython
name: Model Run Open Modelica (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
os: [ubuntu-24.04]
needs: [test_modelica_build]
steps:
- name: Retrieve Open Modelica model binaries
Expand All @@ -85,24 +82,19 @@ jobs:
./Tokamak_Interdependencies
model_run_api:
container:
image: openmodelica/openmodelica:v1.21.0-ompython
image: openmodelica/openmodelica:v1.23.1-ompython
name: Model Run API (${{ matrix.os }} Python${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
python-version: [ '3.11', '3.9', '3.10' ]
os: [ubuntu-24.04]
python-version: [ '3.11', '3.10', '3.12' ]
needs: [test_module_build]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install Poetry
run: python -m pip install poetry
run: python3 -m pip install poetry
- name: Run Models
run: |
poetry install
Expand All @@ -117,24 +109,19 @@ jobs:
retention-days: 1
regression_tests:
container:
image: openmodelica/openmodelica:v1.21.0-ompython
image: openmodelica/openmodelica:v1.23.1-ompython
name: Regression Tests (${{ matrix.os }} Python${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
python-version: [ '3.11', '3.9', '3.10' ]
os: [ubuntu-24.04]
python-version: [ '3.11', '3.10', '3.12' ]
needs: [test_module_build]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install Poetry
run: python -m pip install poetry
run: python3 -m pip install poetry
- name: Run Regression Tests
run: |
poetry install
Expand All @@ -155,18 +142,13 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
python-version: [ '3.11', '3.9', '3.10' ]
os: [ubuntu-24.04]
python-version: [ '3.11', '3.10', '3.12' ]
needs: [test_module_build]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install Poetry
run: python -m pip install poetry
run: python3 -m pip install poetry
- name: Run Unit Tests
run: |
poetry install
Expand All @@ -186,10 +168,8 @@ jobs:
needs: [unit_tests, regression_tests, model_run_api]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
- name: Install Poetry
run: python -m pip install poetry
run: python3 -m pip install poetry
- name: Retrieve Unit Test Coverage
uses: actions/download-artifact@v3
with:
Expand Down
51 changes: 20 additions & 31 deletions .github/workflows/quality_control.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ jobs:
name: Mypy Type Validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"
- name: Install Poetry
run: python -m pip install poetry
- name: Run Mypy
Expand All @@ -20,7 +20,7 @@ jobs:
name: Modelica Syntax Checking
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run Modelica Code Check
run: |
git clone https://github.com/modelica-tools/ModelicaSyntaxChecker.git
Expand All @@ -30,40 +30,29 @@ jobs:
name: Bandit Security Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: jpetrucciani/bandit-check@master
with:
bandit_flags: '-c bandit.yml'
path: power_balance

import_sort:
name: Run Python Import Order Check
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Check Imports
uses: isort/isort-action@master
with:
configuration: '--check-only --diff --profile black'
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1

black_linter:
name: Run Black Python Linter
ruff_linter:
name: Run Ruff Python Linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check Code with Black
uses: psf/black@stable
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
src: power_balance

unused_imports:
name: Run Unused Python Import Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Install Unimport
run: python -m pip install unimport
- name: Check Imports
run: unimport --check --diff --include power_balance
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Run Ruff
run: ruff check --output-format=github .
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: '3.12'
- name: Install Poetry
run: python -m pip install poetry
- name: Check Citation File
Expand Down
47 changes: 16 additions & 31 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
exclude: '^tests|^benchmarks|^docs'
repos:
- repo: https://github.com/hakancelikdev/unimport
rev: 0.9.4
hooks:
- id: unimport
args:
['--remove', '--check', '--include-star-import']
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black"]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.11.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.6.0
hooks:
- id: check-toml
- id: check-merge-conflict
Expand All @@ -26,18 +10,19 @@ repos:
- id: no-commit-to-branch
args: [--branch, main]
- id: check-added-large-files

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.4
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix, "--ignore=C901" ]
- id: ruff-format
- repo: https://github.com/conorfalvey/check_pdb_hook
rev: 0.0.9
hooks:
- id: check_pdb_hook
pass_filenames: false
- repo: https://github.com/PyCQA/bandit.git
rev: 1.7.9
hooks:
- id: mypy
args: []
additional_dependencies:
- types-PyYAML==6.0.1
- types-requests==2.26.3
- types-setuptools==57.4.5
- types-Jinja2>=2.11.9
- types-toml>=0.10.3
- typed-ast>=1.5.2
- types-pkg-resources>=0.1.3
- pydantic>=2.0.0
- id: bandit
args: [-lll, --recursive, clumper]
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# Power Balance Models

[![DOI](https://zenodo.org/badge/450553622.svg)](https://zenodo.org/badge/latestdoi/450553622) [![Power Balance Models Ubuntu](https://github.com/ukaea/powerbalance/actions/workflows/build_run_linux.yml/badge.svg)](https://github.com/ukaea/powerbalance/actions/workflows/build_run_linux.yml) [![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit) [![Python Versions](https://img.shields.io/badge/python-3.9%20|%203.10%20|%203.11%20|%203.12-blue)]() [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![DOI](https://zenodo.org/badge/450553622.svg)](https://zenodo.org/badge/latestdoi/450553622) [![Power Balance Models Ubuntu](https://github.com/ukaea/powerbalance/actions/workflows/build_run_linux.yml/badge.svg)](https://github.com/ukaea/powerbalance/actions/workflows/build_run_linux.yml) [![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit) [![Python Versions](https://img.shields.io/badge/python-3.10%20|%203.11%20|%203.12-blue)]() [![Code style: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

A power balance model which combines power consumption and power generation data to assess the net power production of different designs for a tokamak power plant.

Expand All @@ -21,27 +21,36 @@ It implements a power balance model to bring together power consumption and powe
DISCLAIMER: Parameter values (particularly the ones in the input toml files) do not represent a suitable design point, and may or may not make physical sense. It is up to the user to verify that all parameters are correct.

## Quick Start

It is recommended that Power Balance Models (PBM) be run within a Python virtual environment, you can create one using the pre-installed `venv` python module:

```sh
python -m venv my_venv
source venv/bin/activate
```

then install PBM using `pip` over git:

```sh
pip install git+https://github.com/ukaea/powerbalance.git
```

By default the parameters contained within the models have no physical significance, it is recommended that these be modified to match the scenario for analysis. To do this create a new project folder:

```sh
powerbalance new my_project
```

and modify the parameter files within the directory. You can then execute a run using this directory:

```sh
powerbalance run --param-dir my_project
```

## Updating

Note, if updating your version of `powerbalance` it is strongly recommended that you re-generate the model profiles in case changes have been made which affect them:

```sh
powerbalance generate-profiles
```
Expand All @@ -50,13 +59,13 @@ powerbalance generate-profiles

**NINI model** - This model is based on the in-house UKAEA work of D B King and E Surrey, referred to in the following publication:

Negative ion research at the Culham Centre for Fusion Energy (CCFE), R McAdams, A J T Holmes, D B King, E Surrey, I Turner and J Zacks, New Journal of Physics, Volume 18, December 2016, doi: https://doi.org/10.1088/1367-2630/aa4fa1
Negative ion research at the Culham Centre for Fusion Energy (CCFE), R McAdams, A J T Holmes, D B King, E Surrey, I Turner and J Zacks, New Journal of Physics, Volume 18, December 2016, doi: <https://doi.org/10.1088/1367-2630/aa4fa1>
(R McAdams et al 2016 New J. Phys. 18 125013)

**RF (ECCD) model** - This model is based on the Masters Thesis of Samuel Stewart:

Modelling of Radio Frequency Heating and Current Drive Systems for Nuclear Fusion, Samuel Stewart, Integrated Engineering BEng Thesis, University of Cardiff, April 2021

**Power generation model** - the efficiency values used in the power generation model are derived from a separate Excel model produced by UKAEA. This Excel model built on a body of work produced by the Nuclear Advanced Manufacturing Research Centre and EGB Engineering for UKAEA:
**Power generation model** - the efficiency values used in the power generation model are derived from a separate Excel model produced by UKAEA. This Excel model built on a body of work produced by the Nuclear Advanced Manufacturing Research Centre and EGB Engineering for UKAEA:

"UKAEA STEP WP11: FEASIBILITY STUDY OF MODULAR REACTOR DESIGNS (LOT 2): FEASIBILITY OF ADVANCED NUCLEAR TECHNOLOGIES BALANCE OF PLANT (BOP)"
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM openmodelica/openmodelica:v1.21.0-ompython
ARG msl_version=3.2.3
ARG msl_version=4.0.0
RUN echo "installPackage(Modelica, \"${msl_version}\");" >> install.mos
RUN omc install.mos
RUN rm install.mos
Expand Down
Loading
Loading