Skip to content

Commit 3058ca7

Browse files
committed
Initial: migrate FMU blocks + wrapper from pathsim core
1 parent 30c00d5 commit 3058ca7

34 files changed

Lines changed: 2040 additions & 483 deletions

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
run: pip install -e ".[test]" mypy
4444

4545
- name: mypy
46-
run: mypy src/pathsim_toolbox
46+
run: mypy src/pathsim_fmi
4747

4848
- name: pytest
4949
run: pytest tests/ -v --tb=short

‎README.md‎

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,83 @@
1-
<!-- TEMPLATE:START -->
2-
> **This is the PathSim toolbox template.**
3-
> The README below still contains placeholders. To turn this template into a
4-
> real toolbox, create a repository from it, then run the initializer:
5-
>
6-
> ```bash
7-
> python init.py <name> --description "<one-line description>" --label <Label>
8-
> ```
9-
>
10-
> It renames the package, rewrites every reference, and removes this banner.
11-
> See [`TEMPLATE.md`](TEMPLATE.md) for the full setup, including registering
12-
> the toolbox with the documentation build.
13-
14-
---
15-
<!-- TEMPLATE:END -->
16-
171
<p align="center">
18-
<strong>A toolbox for PathSim</strong>
2+
<strong>FMI/FMU co-simulation toolbox for PathSim</strong>
193
</p>
204

215
<p align="center">
22-
<a href="https://pypi.org/project/pathsim-toolbox/"><img src="https://img.shields.io/pypi/v/pathsim-toolbox" alt="PyPI"></a>
23-
<img src="https://img.shields.io/github/license/pathsim/pathsim-toolbox" alt="License">
6+
<a href="https://pypi.org/project/pathsim-fmi/"><img src="https://img.shields.io/pypi/v/pathsim-fmi" alt="PyPI"></a>
7+
<img src="https://img.shields.io/github/license/pathsim/pathsim-fmi" alt="License">
248
</p>
259

2610
<p align="center">
2711
<a href="https://pathsim.org">Homepage</a> &bull;
28-
<a href="https://docs.pathsim.org/toolbox">Documentation</a> &bull;
29-
<a href="https://github.com/pathsim/pathsim-toolbox">GitHub</a>
12+
<a href="https://docs.pathsim.org/fmi">Documentation</a> &bull;
13+
<a href="https://github.com/pathsim/pathsim-fmi">GitHub</a>
3014
</p>
3115

3216
---
3317

34-
PathSim-Toolbox extends the [PathSim](https://github.com/pathsim/pathsim)
35-
simulation framework with specialized blocks. All blocks follow the standard
36-
PathSim block interface and can be connected into simulation diagrams.
18+
PathSim-FMI extends the [PathSim](https://github.com/pathsim/pathsim)
19+
simulation framework with block wrappers around the
20+
[Functional Mock-up Interface](https://fmi-standard.org/) (FMI 2.0 / 3.0).
21+
Drop an `.fmu` file into a PathSim simulation as either a co-simulation slave
22+
or as a model-exchange system driven by PathSim's own integrators. Built on
23+
top of [FMPy](https://github.com/CATIA-Systems/FMPy).
3724

3825
## Blocks
3926

4027
| Block | Description | Key Parameters |
4128
|-------|-------------|----------------|
42-
| `FirstOrderLag` | First-order lag / low-pass filter | `tau`, `y0` |
29+
| `CoSimulationFMU` | Wrap a Co-Simulation FMU, advanced on a fixed grid `dt` via `fmi*DoStep` | `fmu_path`, `dt`, `start_values` |
30+
| `ModelExchangeFMU` | Wrap a Model-Exchange FMU, integrated by PathSim's solver of choice | `fmu_path`, `start_values` |
31+
| `FMUWrapper` | Lower-level version-agnostic wrapper around FMPy (FMI 2.0 / 3.0) | `fmu_path` |
4332

4433
## Install
4534

4635
```bash
47-
pip install pathsim-toolbox
36+
pip install pathsim-fmi
4837
```
4938

39+
In the PathView web app: install fails on purpose (the FMU runtime needs to
40+
load a native binary via `ctypes`, which Pyodide can't provide). Use the
41+
standalone PathView desktop app or any local Python environment.
42+
5043
## Quick Example
5144

5245
```python
5346
from pathsim import Simulation, Connection
54-
from pathsim.blocks import Source, Scope
55-
from pathsim_toolbox import FirstOrderLag
47+
from pathsim.blocks import Scope
48+
from pathsim_fmi import ModelExchangeFMU
5649

57-
src = Source(lambda t: float(t > 1)) # unit step at t = 1
58-
lag = FirstOrderLag(tau=2.0) # first-order lag
59-
sco = Scope(labels=["input", "output"])
50+
fmu = ModelExchangeFMU("VanDerPol.fmu")
51+
sco = Scope(labels=["x0", "x1"], sampling_period=0.02)
6052

6153
sim = Simulation(
62-
blocks=[src, lag, sco],
54+
blocks=[fmu, sco],
6355
connections=[
64-
Connection(src, lag[0], sco[0]),
65-
Connection(lag, sco[1]),
56+
Connection(fmu[0], sco[0]),
57+
Connection(fmu[1], sco[1]),
6658
],
6759
dt=0.01,
6860
)
69-
sim.run(20)
61+
sim.run(5.0)
7062
sco.plot()
7163
```
7264

7365
## Development
7466

7567
```bash
76-
pip install -e ".[test]" ruff mypy
68+
pip install -e ".[test]" fmpy ruff mypy
7769
ruff check src/ tests/ # lint
7870
ruff format src/ tests/ # format
79-
mypy src/pathsim_toolbox # type check
71+
mypy src/pathsim_fmi # type check
8072
pytest tests/ -v # run tests
8173
```
8274

75+
The test suite uses the official [Modelica Reference-FMUs](https://github.com/modelica/Reference-FMUs)
76+
under `tests/data/reference/` for portable smoke tests, plus a handful of
77+
legacy FMUs (under `tests/data/`) carried over from pathsim-core. The legacy
78+
FMUs ship `darwin64` binaries that are x86_64 only, so the corresponding
79+
tests are auto-skipped on Apple Silicon; CI on Linux runs the full suite.
80+
8381
## License
8482

8583
MIT

‎TEMPLATE.md‎

Lines changed: 0 additions & 114 deletions
This file was deleted.

‎init.py‎

Lines changed: 0 additions & 145 deletions
This file was deleted.

0 commit comments

Comments
 (0)