|
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 | | -
|
17 | 1 | <p align="center"> |
18 | | - <strong>A toolbox for PathSim</strong> |
| 2 | + <strong>FMI/FMU co-simulation toolbox for PathSim</strong> |
19 | 3 | </p> |
20 | 4 |
|
21 | 5 | <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"> |
24 | 8 | </p> |
25 | 9 |
|
26 | 10 | <p align="center"> |
27 | 11 | <a href="https://pathsim.org">Homepage</a> • |
28 | | - <a href="https://docs.pathsim.org/toolbox">Documentation</a> • |
29 | | - <a href="https://github.com/pathsim/pathsim-toolbox">GitHub</a> |
| 12 | + <a href="https://docs.pathsim.org/fmi">Documentation</a> • |
| 13 | + <a href="https://github.com/pathsim/pathsim-fmi">GitHub</a> |
30 | 14 | </p> |
31 | 15 |
|
32 | 16 | --- |
33 | 17 |
|
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). |
37 | 24 |
|
38 | 25 | ## Blocks |
39 | 26 |
|
40 | 27 | | Block | Description | Key Parameters | |
41 | 28 | |-------|-------------|----------------| |
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` | |
43 | 32 |
|
44 | 33 | ## Install |
45 | 34 |
|
46 | 35 | ```bash |
47 | | -pip install pathsim-toolbox |
| 36 | +pip install pathsim-fmi |
48 | 37 | ``` |
49 | 38 |
|
| 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 | + |
50 | 43 | ## Quick Example |
51 | 44 |
|
52 | 45 | ```python |
53 | 46 | 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 |
56 | 49 |
|
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) |
60 | 52 |
|
61 | 53 | sim = Simulation( |
62 | | - blocks=[src, lag, sco], |
| 54 | + blocks=[fmu, sco], |
63 | 55 | 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]), |
66 | 58 | ], |
67 | 59 | dt=0.01, |
68 | 60 | ) |
69 | | -sim.run(20) |
| 61 | +sim.run(5.0) |
70 | 62 | sco.plot() |
71 | 63 | ``` |
72 | 64 |
|
73 | 65 | ## Development |
74 | 66 |
|
75 | 67 | ```bash |
76 | | -pip install -e ".[test]" ruff mypy |
| 68 | +pip install -e ".[test]" fmpy ruff mypy |
77 | 69 | ruff check src/ tests/ # lint |
78 | 70 | ruff format src/ tests/ # format |
79 | | -mypy src/pathsim_toolbox # type check |
| 71 | +mypy src/pathsim_fmi # type check |
80 | 72 | pytest tests/ -v # run tests |
81 | 73 | ``` |
82 | 74 |
|
| 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 | + |
83 | 81 | ## License |
84 | 82 |
|
85 | 83 | MIT |
0 commit comments