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

Add pre-commit config #10

Merged
merged 6 commits into from
Feb 21, 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
22 changes: 0 additions & 22 deletions .github/workflows/check-pep8.yml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Code Style
on:
push:
branches:
- main
- develop
pull_request:
branches:
- "*"

jobs:
formatting:
runs-on: ubuntu-latest
steps:
- name: Checkout the FMI Runner
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.10'
check-latest: true
- name: Install pre-commit
run: pip install pre-commit
- name: Run checks
run: pre-commit run -a -v
- name: Git status
if: always()
run: git status
- name: Full diff
if: always()
run: git diff
5 changes: 5 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"MD013": false,
"MD033": false,
"MD034": false
}
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
# Official repo for default hooks
- repo: https://github.com/precice/precice-pre-commit-hooks
rev: 'v3.2'
hooks:
- id: format-precice-config
files: "^.*/precice-config.xml"
- id: check-image-prefix
args: [ --prefix=docs-tooling-fmi-runner- ]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.39.0
hooks:
- id: markdownlint
files: "^docs/.*.md"
- id: markdownlint-fix
files: "^docs/.*.md"
- repo: https://github.com/hhatto/autopep8
rev: v2.0.4
hooks:
- id: autopep8
args: [ --in-place, --ignore=E402, --max-line-length=120 ]
19 changes: 9 additions & 10 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ summary: A tool to execute FMUs and couple them to PDE-based solvers using preCI

The [Functional Mock-Up Interface](https://fmi-standard.org/) (FMI) is a standard for the exchange of dynamic simulation models. Currently, it is the de-facto industry standard for co-simulation. Models implementing the FMI standard are called Functional Mock-Up Units (FMU).

The preCICE-FMI runner contains the script `fmiprecice` to couple FMU models with other simulation tools via [preCICE](https://precice.org/). The runner serves as an importer for the FMU to steer the simulation. Additionally, the runner calls the preCICE library to communicate and coordinate with other solvers.
The preCICE-FMI runner contains the script `fmiprecice` to couple FMU models with other simulation tools via [preCICE](https://precice.org/). The runner serves as an importer for the FMU to steer the simulation. Additionally, the runner calls the preCICE library to communicate and coordinate with other solvers.

![img](images/tooling-fmi-runner-setup.png)
![img](images/docs-tooling-fmi-runner-setup.png)

## Usage

Expand All @@ -21,7 +21,7 @@ The runner is called from the terminal with the command `fmiprecice`. It takes t
fmiprecice ./fmi-settings.json ./precice-settings.json
```

Read on to find out how to install and configure the runner. More information about the software, its abilities, and its limitations can be found in [1]. If you are ready to run your first case, have a look at the [oscillator tutorial](https://github.com/LeonardWilleke/precice-tutorials/tree/create-fmu-oscillator-v2/oscillator).
Read on to find out how to install and configure the runner. More information about the software, its abilities, and its limitations can be found in [1]. If you are ready to run your first case, have a look at the [oscillator tutorial](https://github.com/LeonardWilleke/precice-tutorials/tree/create-fmu-oscillator-v2/oscillator).

## Get the Runner

Expand All @@ -43,7 +43,7 @@ pip3 install numpy
pip3 install fmpy
```

### Installation
### Installation

The software is [hosted on GitHub](https://github.com/precice/fmi-runner). Clone the repository and switch to the root directory:

Expand Down Expand Up @@ -93,8 +93,8 @@ The file `fmi-settings.json` holds all the necessary information to run a simula
"output": ["force", "position"]
},
"model_params": {
"apply_filter": true,
"spring_coeff": 65.0
"apply_filter": true,
"spring_coeff": 65.0
},
"initial_conditions": {
"position": 0.0
Expand Down Expand Up @@ -157,9 +157,9 @@ The file `precice-settings.json` is used to configure the coupling with preCICE.

Current limitations of the FMI runner software are:

- Can only be used with preCICE v2 and Co-Simulation FMUs (FMI 1,2,3)
- All accessed FMU variables are scalar
- Data can only be exchanged via one vertex. The exchange of multiple vertices or full meshes is not possible.
* Can only be used with preCICE v2 and Co-Simulation FMUs (FMI 1,2,3)
* All accessed FMU variables are scalar
* Data can only be exchanged via one vertex. The exchange of multiple vertices or full meshes is not possible.

## How to cite

Expand All @@ -180,4 +180,3 @@ If you are using the FMI runner, pĺease consider citing the following Thesis:
## References

[1] L. Willeke, [A preCICE-FMI Runner to couple controller models to PDEs](https://doi.org/10.18419/opus-13130), Master Thesis, University of Stuttgart, 2023

57 changes: 30 additions & 27 deletions tests/precice-config.xml
Original file line number Diff line number Diff line change
@@ -1,50 +1,53 @@
<?xml version="1.0"?>

<?xml version="1.0" encoding="UTF-8" ?>
<precice-configuration>

<log>
<sink type="stream" output="stdout" filter= "%Severity% > debug" format="preCICE:%ColorizedSeverity% %Message%" enabled="true" />
<sink
type="stream"
output="stdout"
filter="%Severity% > debug"
format="preCICE:%ColorizedSeverity% %Message%"
enabled="true" />
</log>

<solver-interface dimensions="2" >

<data:scalar name="dataOne" />
<data:scalar name="dataTwo" />

<solver-interface dimensions="2">
<data:scalar name="dataOne" />
<data:scalar name="dataTwo" />
<mesh name="MeshOne">
<use-data name="dataOne" />
<use-data name="dataTwo" />
</mesh>

<mesh name="MeshTwo">
<use-data name="dataOne" />
<use-data name="dataTwo" />
</mesh>

<participant name="SolverOne">
<use-mesh name="MeshOne" provide="yes"/>
<use-mesh name="MeshOne" provide="yes" />
<write-data name="dataOne" mesh="MeshOne" />
<read-data name="dataTwo" mesh="MeshOne" />
<read-data name="dataTwo" mesh="MeshOne" />
</participant>

<participant name="SolverTwo">
<use-mesh name="MeshOne" from="SolverOne"/>
<use-mesh name="MeshTwo" provide="yes"/>
<mapping:nearest-neighbor direction="write" from="MeshTwo" to="MeshOne" constraint="conservative"/>
<mapping:nearest-neighbor direction="read" from="MeshOne" to="MeshTwo" constraint="consistent" />
<use-mesh name="MeshOne" from="SolverOne" />
<use-mesh name="MeshTwo" provide="yes" />
<mapping:nearest-neighbor
direction="write"
from="MeshTwo"
to="MeshOne"
constraint="conservative" />
<mapping:nearest-neighbor
direction="read"
from="MeshOne"
to="MeshTwo"
constraint="consistent" />
<write-data name="dataTwo" mesh="MeshTwo" />
<read-data name="dataOne" mesh="MeshTwo" />
<read-data name="dataOne" mesh="MeshTwo" />
</participant>

<m2n:sockets from="SolverOne" to="SolverTwo" exchange-directory=".."/>

<coupling-scheme:serial-explicit>
<participants first="SolverOne" second="SolverTwo" />
<m2n:sockets from="SolverOne" to="SolverTwo" exchange-directory=".." />
<coupling-scheme:serial-explicit>
<participants first="SolverOne" second="SolverTwo" />
<max-time-windows value="5" />
<time-window-size value="1.0" />
<exchange data="dataOne" mesh="MeshOne" from="SolverOne" to="SolverTwo" />
<exchange data="dataTwo" mesh="MeshOne" from="SolverTwo" to="SolverOne"/>
</coupling-scheme:serial-explicit>
<exchange data="dataTwo" mesh="MeshOne" from="SolverTwo" to="SolverOne" />
</coupling-scheme:serial-explicit>
</solver-interface>

</precice-configuration>
Loading