pathsim-fusion 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pathsim_fusion-0.1.0/.github/workflows/ci.yml +50 -0
- pathsim_fusion-0.1.0/.github/workflows/publish.yml +31 -0
- pathsim_fusion-0.1.0/.gitignore +85 -0
- pathsim_fusion-0.1.0/LICENSE +21 -0
- pathsim_fusion-0.1.0/PKG-INFO +107 -0
- pathsim_fusion-0.1.0/README.md +73 -0
- pathsim_fusion-0.1.0/docs/source/examples/linear_feedback.ipynb +213 -0
- pathsim_fusion-0.1.0/docs/source/pathsim_docs.mplstyle +74 -0
- pathsim_fusion-0.1.0/environment.yml +27 -0
- pathsim_fusion-0.1.0/pyproject.toml +78 -0
- pathsim_fusion-0.1.0/setup.cfg +4 -0
- pathsim_fusion-0.1.0/src/pathsim_fusion/__init__.py +29 -0
- pathsim_fusion-0.1.0/src/pathsim_fusion/_version.py +24 -0
- pathsim_fusion-0.1.0/src/pathsim_fusion/tritium/__init__.py +5 -0
- pathsim_fusion-0.1.0/src/pathsim_fusion/tritium/bubbler.py +240 -0
- pathsim_fusion-0.1.0/src/pathsim_fusion/tritium/glc.py +537 -0
- pathsim_fusion-0.1.0/src/pathsim_fusion/tritium/ionisation_chamber.py +96 -0
- pathsim_fusion-0.1.0/src/pathsim_fusion.egg-info/PKG-INFO +107 -0
- pathsim_fusion-0.1.0/src/pathsim_fusion.egg-info/SOURCES.txt +27 -0
- pathsim_fusion-0.1.0/src/pathsim_fusion.egg-info/dependency_links.txt +1 -0
- pathsim_fusion-0.1.0/src/pathsim_fusion.egg-info/requires.txt +10 -0
- pathsim_fusion-0.1.0/src/pathsim_fusion.egg-info/scm_file_list.json +23 -0
- pathsim_fusion-0.1.0/src/pathsim_fusion.egg-info/scm_version.json +8 -0
- pathsim_fusion-0.1.0/src/pathsim_fusion.egg-info/top_level.txt +1 -0
- pathsim_fusion-0.1.0/tests/__init__.py +0 -0
- pathsim_fusion-0.1.0/tests/tritium/__init__.py +0 -0
- pathsim_fusion-0.1.0/tests/tritium/test_bubbler.py +261 -0
- pathsim_fusion-0.1.0/tests/tritium/test_glc.py +272 -0
- pathsim_fusion-0.1.0/tests/tritium/test_ionisation_chamber.py +117 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master, main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
lint:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
# ruff version is read from the `lint` extra in pyproject.toml
|
|
16
|
+
- name: ruff check
|
|
17
|
+
uses: astral-sh/ruff-action@v3
|
|
18
|
+
with:
|
|
19
|
+
version-file: pyproject.toml
|
|
20
|
+
args: check
|
|
21
|
+
|
|
22
|
+
- name: ruff format
|
|
23
|
+
uses: astral-sh/ruff-action@v3
|
|
24
|
+
with:
|
|
25
|
+
version-file: pyproject.toml
|
|
26
|
+
args: format --check
|
|
27
|
+
|
|
28
|
+
test:
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
strategy:
|
|
31
|
+
matrix:
|
|
32
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
33
|
+
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v4
|
|
36
|
+
with:
|
|
37
|
+
fetch-depth: 0 # full history so setuptools-scm can derive the version
|
|
38
|
+
|
|
39
|
+
- uses: actions/setup-python@v5
|
|
40
|
+
with:
|
|
41
|
+
python-version: ${{ matrix.python-version }}
|
|
42
|
+
|
|
43
|
+
- name: Install
|
|
44
|
+
run: pip install -e ".[test]" mypy
|
|
45
|
+
|
|
46
|
+
- name: mypy
|
|
47
|
+
run: mypy src/pathsim_fusion
|
|
48
|
+
|
|
49
|
+
- name: pytest
|
|
50
|
+
run: pytest tests/ -v --tb=short
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
id-token: write # trusted publishing — no API token needed
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
publish:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
environment: pypi
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0 # full history so setuptools-scm derives the release version
|
|
20
|
+
|
|
21
|
+
- uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: "3.x"
|
|
24
|
+
|
|
25
|
+
- name: Build package
|
|
26
|
+
run: |
|
|
27
|
+
pip install build
|
|
28
|
+
python -m build
|
|
29
|
+
|
|
30
|
+
- name: Publish package
|
|
31
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Notebooks (except documentation notebooks)
|
|
10
|
+
*.ipynb
|
|
11
|
+
!docs/**/*.ipynb
|
|
12
|
+
|
|
13
|
+
# Distribution / packaging
|
|
14
|
+
.Python
|
|
15
|
+
build/
|
|
16
|
+
develop-eggs/
|
|
17
|
+
dist/
|
|
18
|
+
downloads/
|
|
19
|
+
eggs/
|
|
20
|
+
.eggs/
|
|
21
|
+
lib/
|
|
22
|
+
lib64/
|
|
23
|
+
parts/
|
|
24
|
+
sdist/
|
|
25
|
+
var/
|
|
26
|
+
wheels/
|
|
27
|
+
*.egg-info/
|
|
28
|
+
.installed.cfg
|
|
29
|
+
*.egg
|
|
30
|
+
*.pypirc
|
|
31
|
+
|
|
32
|
+
# Installer logs
|
|
33
|
+
pip-log.txt
|
|
34
|
+
pip-delete-this-directory.txt
|
|
35
|
+
|
|
36
|
+
# Unit test / coverage reports
|
|
37
|
+
htmlcov/
|
|
38
|
+
.tox/
|
|
39
|
+
.coverage
|
|
40
|
+
.coverage.*
|
|
41
|
+
.cache
|
|
42
|
+
nosetests.xml
|
|
43
|
+
coverage.xml
|
|
44
|
+
*.cover
|
|
45
|
+
.hypothesis/
|
|
46
|
+
test_reports/
|
|
47
|
+
*.pyc
|
|
48
|
+
.pytest_cache/
|
|
49
|
+
.mypy_cache/
|
|
50
|
+
.ruff_cache/
|
|
51
|
+
|
|
52
|
+
# Jupyter Notebook
|
|
53
|
+
.ipynb_checkpoints
|
|
54
|
+
|
|
55
|
+
# pyenv
|
|
56
|
+
.python-version
|
|
57
|
+
|
|
58
|
+
# Environment
|
|
59
|
+
.env
|
|
60
|
+
.venv
|
|
61
|
+
env/
|
|
62
|
+
venv/
|
|
63
|
+
ENV/
|
|
64
|
+
|
|
65
|
+
# Shell
|
|
66
|
+
*.bat
|
|
67
|
+
|
|
68
|
+
# IDEs
|
|
69
|
+
.vscode/
|
|
70
|
+
.idea/
|
|
71
|
+
|
|
72
|
+
# OS generated files
|
|
73
|
+
.DS_Store
|
|
74
|
+
.DS_Store?
|
|
75
|
+
._*
|
|
76
|
+
.Spotlight-V100
|
|
77
|
+
.Trashes
|
|
78
|
+
ehthumbs.db
|
|
79
|
+
Thumbs.db
|
|
80
|
+
|
|
81
|
+
# Claude
|
|
82
|
+
.claude
|
|
83
|
+
|
|
84
|
+
# setuptools-scm generated version file
|
|
85
|
+
_version.py
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 PathSim
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pathsim-fusion
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Fusion fuel cycle and balance-of-plant blocks for PathSim
|
|
5
|
+
Author: PathSim Contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://pathsim.org
|
|
8
|
+
Project-URL: Documentation, https://docs.pathsim.org/fusion
|
|
9
|
+
Project-URL: Repository, https://github.com/pathsim/pathsim-fusion
|
|
10
|
+
Project-URL: Issues, https://github.com/pathsim/pathsim-fusion/issues
|
|
11
|
+
Keywords: simulation,pathsim,block diagram,fusion,tritium,fuel cycle,balance of plant
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: pathsim>=0.23
|
|
26
|
+
Requires-Dist: numpy>=1.15
|
|
27
|
+
Requires-Dist: scipy>=1.2
|
|
28
|
+
Provides-Extra: test
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
30
|
+
Requires-Dist: pytest-cov>=4.0; extra == "test"
|
|
31
|
+
Provides-Extra: lint
|
|
32
|
+
Requires-Dist: ruff==0.17.3; extra == "lint"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
<p align="center">
|
|
36
|
+
<strong>Fusion fuel cycle and balance-of-plant blocks for PathSim</strong>
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
<p align="center">
|
|
40
|
+
<a href="https://pypi.org/project/pathsim-fusion/"><img src="https://img.shields.io/pypi/v/pathsim-fusion" alt="PyPI"></a>
|
|
41
|
+
<img src="https://img.shields.io/github/license/pathsim/pathsim-fusion" alt="License">
|
|
42
|
+
</p>
|
|
43
|
+
|
|
44
|
+
<p align="center">
|
|
45
|
+
<a href="https://pathsim.org">Homepage</a> •
|
|
46
|
+
<a href="https://docs.pathsim.org/fusion">Documentation</a> •
|
|
47
|
+
<a href="https://github.com/pathsim/pathsim-fusion">GitHub</a>
|
|
48
|
+
</p>
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
PathSim-Fusion extends the [PathSim](https://github.com/pathsim/pathsim)
|
|
53
|
+
simulation framework with specialized blocks. All blocks follow the standard
|
|
54
|
+
PathSim block interface and can be connected into simulation diagrams.
|
|
55
|
+
|
|
56
|
+
## Blocks
|
|
57
|
+
|
|
58
|
+
| Block | Description | Key Parameters |
|
|
59
|
+
|-------|-------------|----------------|
|
|
60
|
+
| `IonisationChamber` | Flow-through tritium ionisation chamber (signal = ε(c)·c, flux passes through) | `detection_efficiency`, `detection_threshold` |
|
|
61
|
+
| `Bubbler4` | Four-vial tritium sampling bubbler (soluble + insoluble chains, catalytic conversion, scheduled vial replacement) | `conversion_efficiency`, `vial_efficiency`, `replacement_times` |
|
|
62
|
+
| `GLC` | Counter-current bubble-column gas–liquid contactor for tritium extraction from LiPb (Malara 1995, on `BVP1D`) | `P_in`, `L`, `D`, `T`, `BCs` |
|
|
63
|
+
|
|
64
|
+
## Install
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install pathsim-fusion
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Quick Example
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from pathsim import Simulation, Connection
|
|
74
|
+
from pathsim.blocks import Constant, Source, Scope
|
|
75
|
+
from pathsim_fusion import IonisationChamber
|
|
76
|
+
|
|
77
|
+
flux = Source(lambda t: 1e-3 * float(t > 1)) # tritium flux, step at t = 1
|
|
78
|
+
flow = Constant(0.5) # carrier gas flow rate
|
|
79
|
+
ic = IonisationChamber(detection_efficiency=0.9)
|
|
80
|
+
sco = Scope(labels=["flux", "signal"])
|
|
81
|
+
|
|
82
|
+
sim = Simulation(
|
|
83
|
+
blocks=[flux, flow, ic, sco],
|
|
84
|
+
connections=[
|
|
85
|
+
Connection(flux, ic["flux_in"], sco[0]),
|
|
86
|
+
Connection(flow, ic["flow_rate"]),
|
|
87
|
+
Connection(ic["signal"], sco[1]),
|
|
88
|
+
],
|
|
89
|
+
dt=0.01,
|
|
90
|
+
)
|
|
91
|
+
sim.run(5)
|
|
92
|
+
sco.plot()
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Development
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pip install -e ".[test,lint]" mypy
|
|
99
|
+
ruff check . # lint
|
|
100
|
+
ruff format . # format
|
|
101
|
+
mypy src/pathsim_fusion # type check
|
|
102
|
+
pytest tests/ -v # run tests
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
MIT
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<strong>Fusion fuel cycle and balance-of-plant blocks for PathSim</strong>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://pypi.org/project/pathsim-fusion/"><img src="https://img.shields.io/pypi/v/pathsim-fusion" alt="PyPI"></a>
|
|
7
|
+
<img src="https://img.shields.io/github/license/pathsim/pathsim-fusion" alt="License">
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="https://pathsim.org">Homepage</a> •
|
|
12
|
+
<a href="https://docs.pathsim.org/fusion">Documentation</a> •
|
|
13
|
+
<a href="https://github.com/pathsim/pathsim-fusion">GitHub</a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
PathSim-Fusion extends the [PathSim](https://github.com/pathsim/pathsim)
|
|
19
|
+
simulation framework with specialized blocks. All blocks follow the standard
|
|
20
|
+
PathSim block interface and can be connected into simulation diagrams.
|
|
21
|
+
|
|
22
|
+
## Blocks
|
|
23
|
+
|
|
24
|
+
| Block | Description | Key Parameters |
|
|
25
|
+
|-------|-------------|----------------|
|
|
26
|
+
| `IonisationChamber` | Flow-through tritium ionisation chamber (signal = ε(c)·c, flux passes through) | `detection_efficiency`, `detection_threshold` |
|
|
27
|
+
| `Bubbler4` | Four-vial tritium sampling bubbler (soluble + insoluble chains, catalytic conversion, scheduled vial replacement) | `conversion_efficiency`, `vial_efficiency`, `replacement_times` |
|
|
28
|
+
| `GLC` | Counter-current bubble-column gas–liquid contactor for tritium extraction from LiPb (Malara 1995, on `BVP1D`) | `P_in`, `L`, `D`, `T`, `BCs` |
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install pathsim-fusion
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick Example
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from pathsim import Simulation, Connection
|
|
40
|
+
from pathsim.blocks import Constant, Source, Scope
|
|
41
|
+
from pathsim_fusion import IonisationChamber
|
|
42
|
+
|
|
43
|
+
flux = Source(lambda t: 1e-3 * float(t > 1)) # tritium flux, step at t = 1
|
|
44
|
+
flow = Constant(0.5) # carrier gas flow rate
|
|
45
|
+
ic = IonisationChamber(detection_efficiency=0.9)
|
|
46
|
+
sco = Scope(labels=["flux", "signal"])
|
|
47
|
+
|
|
48
|
+
sim = Simulation(
|
|
49
|
+
blocks=[flux, flow, ic, sco],
|
|
50
|
+
connections=[
|
|
51
|
+
Connection(flux, ic["flux_in"], sco[0]),
|
|
52
|
+
Connection(flow, ic["flow_rate"]),
|
|
53
|
+
Connection(ic["signal"], sco[1]),
|
|
54
|
+
],
|
|
55
|
+
dt=0.01,
|
|
56
|
+
)
|
|
57
|
+
sim.run(5)
|
|
58
|
+
sco.plot()
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Development
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install -e ".[test,lint]" mypy
|
|
65
|
+
ruff check . # lint
|
|
66
|
+
ruff format . # format
|
|
67
|
+
mypy src/pathsim_fusion # type check
|
|
68
|
+
pytest tests/ -v # run tests
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"id": "0",
|
|
6
|
+
"metadata": {},
|
|
7
|
+
"source": "# Linear Feedback System\n\nSimulation of a simple linear feedback system with step response.\n\nYou can also find this example as a single file in the [GitHub repository](https://github.com/milanofthe/pathsim/blob/master/examples/example_feedback.py)."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"cell_type": "raw",
|
|
11
|
+
"id": "1",
|
|
12
|
+
"metadata": {
|
|
13
|
+
"raw_mimetype": "text/restructuredtext"
|
|
14
|
+
},
|
|
15
|
+
"source": [
|
|
16
|
+
".. image:: figures/figures_g/linear_feedback_blockdiagram_g.png\n",
|
|
17
|
+
" :width: 700\n",
|
|
18
|
+
" :align: center\n",
|
|
19
|
+
" :alt: block diagram of linear feedback system"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"cell_type": "raw",
|
|
24
|
+
"id": "2",
|
|
25
|
+
"metadata": {
|
|
26
|
+
"raw_mimetype": "text/restructuredtext"
|
|
27
|
+
},
|
|
28
|
+
"source": [
|
|
29
|
+
"The block diagramm above can be translated to a netlist by using the blocks and the connection class provided by PathSim. First lets import the :class:`.Simulation` and :class:`.Connection` classes and the required blocks from the block library:"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"cell_type": "code",
|
|
34
|
+
"execution_count": null,
|
|
35
|
+
"id": "3",
|
|
36
|
+
"metadata": {},
|
|
37
|
+
"outputs": [],
|
|
38
|
+
"source": [
|
|
39
|
+
"import matplotlib.pyplot as plt\n",
|
|
40
|
+
"\n",
|
|
41
|
+
"# Apply PathSim docs matplotlib style for consistent, theme-friendly figures\n",
|
|
42
|
+
"plt.style.use(\"../pathsim_docs.mplstyle\")\n",
|
|
43
|
+
"\n",
|
|
44
|
+
"from pathsim import Connection, Simulation\n",
|
|
45
|
+
"from pathsim.blocks import Adder, Amplifier, Integrator, Scope, Source"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"cell_type": "markdown",
|
|
50
|
+
"id": "4",
|
|
51
|
+
"metadata": {},
|
|
52
|
+
"source": [
|
|
53
|
+
"Then lets define the system parameters such as the initial value `x0` of the integrator, the linear feedback gain `a` and the time dependend source function `s(t)`."
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"cell_type": "code",
|
|
58
|
+
"execution_count": null,
|
|
59
|
+
"id": "5",
|
|
60
|
+
"metadata": {},
|
|
61
|
+
"outputs": [],
|
|
62
|
+
"source": [
|
|
63
|
+
"# System parameters\n",
|
|
64
|
+
"a, x0 = -1, 2\n",
|
|
65
|
+
"\n",
|
|
66
|
+
"# Delay for step function\n",
|
|
67
|
+
"tau = 3\n",
|
|
68
|
+
"\n",
|
|
69
|
+
"\n",
|
|
70
|
+
"# Step function\n",
|
|
71
|
+
"def s(t):\n",
|
|
72
|
+
" return int(t > tau)"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"cell_type": "markdown",
|
|
77
|
+
"id": "6",
|
|
78
|
+
"metadata": {},
|
|
79
|
+
"source": [
|
|
80
|
+
"Now we can construct the system by instantiating the blocks we need with their corresponding prameters and collect them together in a list:"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"cell_type": "code",
|
|
85
|
+
"execution_count": null,
|
|
86
|
+
"id": "7",
|
|
87
|
+
"metadata": {},
|
|
88
|
+
"outputs": [],
|
|
89
|
+
"source": [
|
|
90
|
+
"# Blocks that define the system\n",
|
|
91
|
+
"Src = Source(s)\n",
|
|
92
|
+
"Int = Integrator(x0)\n",
|
|
93
|
+
"Amp = Amplifier(a)\n",
|
|
94
|
+
"Add = Adder()\n",
|
|
95
|
+
"Sco = Scope(labels=[\"step\", \"response\"])\n",
|
|
96
|
+
"\n",
|
|
97
|
+
"blocks = [Src, Int, Amp, Add, Sco]"
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"cell_type": "raw",
|
|
102
|
+
"id": "8",
|
|
103
|
+
"metadata": {
|
|
104
|
+
"raw_mimetype": "text/restructuredtext"
|
|
105
|
+
},
|
|
106
|
+
"source": [
|
|
107
|
+
"Afterwards, the connections between the blocks can be defined. The first argument of the :class:`.Connection` class is the source block and its port (``Src[0]`` would be port ``0`` of the instance of the :class:`.Source` block, which is also the default port)."
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"cell_type": "code",
|
|
112
|
+
"execution_count": null,
|
|
113
|
+
"id": "9",
|
|
114
|
+
"metadata": {},
|
|
115
|
+
"outputs": [],
|
|
116
|
+
"source": [
|
|
117
|
+
"# The connections between the blocks\n",
|
|
118
|
+
"connections = [\n",
|
|
119
|
+
" Connection(Src, Add[0], Sco[0]),\n",
|
|
120
|
+
" Connection(Amp, Add[1]),\n",
|
|
121
|
+
" Connection(Add, Int),\n",
|
|
122
|
+
" Connection(Int, Amp, Sco[1]),\n",
|
|
123
|
+
"]"
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"cell_type": "raw",
|
|
128
|
+
"id": "10",
|
|
129
|
+
"metadata": {
|
|
130
|
+
"raw_mimetype": "text/restructuredtext"
|
|
131
|
+
},
|
|
132
|
+
"source": [
|
|
133
|
+
"Finally we can instantiate the ``Simulation`` with the blocks, connections and some additional parameters such as the timestep. In this case, no special ODE solver is specified, so PathSim uses the default :class:`.SSPRK22` integrator which is a fixed step 2nd order explicit Runge-Kutta method. A good starting point. Then we can run the simulation for some duration which is set as ``4*tau`` in this example."
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"cell_type": "code",
|
|
138
|
+
"execution_count": null,
|
|
139
|
+
"id": "11",
|
|
140
|
+
"metadata": {},
|
|
141
|
+
"outputs": [],
|
|
142
|
+
"source": [
|
|
143
|
+
"# Initialize simulation with the blocks, connections, timestep\n",
|
|
144
|
+
"Sim = Simulation(blocks, connections, dt=0.01, log=True)\n",
|
|
145
|
+
"\n",
|
|
146
|
+
"# Run the simulation for some time\n",
|
|
147
|
+
"Sim.run(4 * tau)"
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"cell_type": "raw",
|
|
152
|
+
"id": "12",
|
|
153
|
+
"metadata": {
|
|
154
|
+
"raw_mimetype": "text/restructuredtext"
|
|
155
|
+
},
|
|
156
|
+
"source": [
|
|
157
|
+
"Due to the object oriented and decentralized nature of PathSim, the :class:`.Scope` block holds the recorded time series data from the simulation internally. It can be accessed by its ``read`` method"
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"cell_type": "code",
|
|
162
|
+
"execution_count": null,
|
|
163
|
+
"id": "13",
|
|
164
|
+
"metadata": {},
|
|
165
|
+
"outputs": [],
|
|
166
|
+
"source": [
|
|
167
|
+
"# Read the data from the scope\n",
|
|
168
|
+
"time, [data_step, data_response] = Sco.read()"
|
|
169
|
+
]
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"cell_type": "markdown",
|
|
173
|
+
"id": "14",
|
|
174
|
+
"metadata": {},
|
|
175
|
+
"source": [
|
|
176
|
+
"or plotted directly in an external matplotlib window using the `plot` method"
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"cell_type": "code",
|
|
181
|
+
"execution_count": null,
|
|
182
|
+
"id": "15",
|
|
183
|
+
"metadata": {},
|
|
184
|
+
"outputs": [],
|
|
185
|
+
"source": [
|
|
186
|
+
"# Plot the results from the scope\n",
|
|
187
|
+
"fig, ax = Sco.plot()\n",
|
|
188
|
+
"plt.show()"
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
"metadata": {
|
|
193
|
+
"kernelspec": {
|
|
194
|
+
"display_name": "Python [conda env:base] *",
|
|
195
|
+
"language": "python",
|
|
196
|
+
"name": "conda-base-py"
|
|
197
|
+
},
|
|
198
|
+
"language_info": {
|
|
199
|
+
"codemirror_mode": {
|
|
200
|
+
"name": "ipython",
|
|
201
|
+
"version": 3
|
|
202
|
+
},
|
|
203
|
+
"file_extension": ".py",
|
|
204
|
+
"mimetype": "text/x-python",
|
|
205
|
+
"name": "python",
|
|
206
|
+
"nbconvert_exporter": "python",
|
|
207
|
+
"pygments_lexer": "ipython3",
|
|
208
|
+
"version": "3.12.7"
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
"nbformat": 4,
|
|
212
|
+
"nbformat_minor": 5
|
|
213
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# PathSim documentation matplotlib style
|
|
2
|
+
# Optimized for light/dark mode compatibility with transparent backgrounds
|
|
3
|
+
|
|
4
|
+
# Figure
|
|
5
|
+
figure.figsize: 8, 4
|
|
6
|
+
figure.dpi: 300
|
|
7
|
+
figure.facecolor: none
|
|
8
|
+
figure.edgecolor: none
|
|
9
|
+
savefig.facecolor: none
|
|
10
|
+
savefig.edgecolor: none
|
|
11
|
+
savefig.transparent: True
|
|
12
|
+
savefig.bbox: tight
|
|
13
|
+
savefig.pad_inches: 0.1
|
|
14
|
+
|
|
15
|
+
# Axes
|
|
16
|
+
axes.facecolor: none
|
|
17
|
+
axes.edgecolor: "#7F7F7F"
|
|
18
|
+
axes.linewidth: 1.8
|
|
19
|
+
axes.grid: False
|
|
20
|
+
axes.axisbelow: True
|
|
21
|
+
axes.labelsize: 11
|
|
22
|
+
axes.titlesize: 12
|
|
23
|
+
axes.labelcolor: "#7F7F7F"
|
|
24
|
+
axes.titleweight: bold
|
|
25
|
+
axes.spines.top: False
|
|
26
|
+
axes.spines.right: False
|
|
27
|
+
|
|
28
|
+
# Grid
|
|
29
|
+
grid.color: "#7F7F7F"
|
|
30
|
+
grid.linestyle: --
|
|
31
|
+
grid.linewidth: 0.8
|
|
32
|
+
grid.alpha: 0.6
|
|
33
|
+
|
|
34
|
+
# Lines
|
|
35
|
+
lines.linewidth: 2.0
|
|
36
|
+
lines.markersize: 8
|
|
37
|
+
lines.markeredgewidth: 1.5
|
|
38
|
+
lines.antialiased: True
|
|
39
|
+
|
|
40
|
+
# Patches (for bars, etc.)
|
|
41
|
+
patch.linewidth: 1.0
|
|
42
|
+
patch.facecolor: 4C72B0
|
|
43
|
+
patch.edgecolor: none
|
|
44
|
+
patch.antialiased: True
|
|
45
|
+
|
|
46
|
+
# Font
|
|
47
|
+
font.family: sans-serif
|
|
48
|
+
font.sans-serif: DejaVu Sans, Arial, Helvetica, sans-serif
|
|
49
|
+
font.size: 10
|
|
50
|
+
text.color: "#7F7F7F"
|
|
51
|
+
|
|
52
|
+
# Legend
|
|
53
|
+
legend.frameon: False
|
|
54
|
+
legend.framealpha: 0.0
|
|
55
|
+
legend.fancybox: False
|
|
56
|
+
legend.facecolor: none
|
|
57
|
+
legend.edgecolor: none
|
|
58
|
+
legend.fontsize: 10
|
|
59
|
+
legend.loc: best
|
|
60
|
+
|
|
61
|
+
# Ticks
|
|
62
|
+
xtick.labelsize: 10
|
|
63
|
+
ytick.labelsize: 10
|
|
64
|
+
xtick.color: "#7F7F7F"
|
|
65
|
+
ytick.color: "#7F7F7F"
|
|
66
|
+
xtick.direction: out
|
|
67
|
+
ytick.direction: out
|
|
68
|
+
xtick.major.width: 1.8
|
|
69
|
+
ytick.major.width: 1.8
|
|
70
|
+
xtick.minor.width: 1.2
|
|
71
|
+
ytick.minor.width: 1.2
|
|
72
|
+
|
|
73
|
+
# Color cycle - colors that work well with grey text
|
|
74
|
+
axes.prop_cycle: cycler('color', ['e41a1c', '377eb8', '4daf4a', '984ea3', 'ff7f00'])
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Development environment for pathsim-fusion.
|
|
2
|
+
#
|
|
3
|
+
# conda env create -f environment.yml
|
|
4
|
+
# conda activate pathsim-fusion
|
|
5
|
+
#
|
|
6
|
+
# Update after changing dependencies:
|
|
7
|
+
#
|
|
8
|
+
# conda env update -f environment.yml --prune
|
|
9
|
+
#
|
|
10
|
+
# pathsim itself comes from PyPI via the package's own dependencies. To develop
|
|
11
|
+
# against a local checkout of core instead, run afterwards:
|
|
12
|
+
#
|
|
13
|
+
# pip install -e ../pathsim
|
|
14
|
+
|
|
15
|
+
name: pathsim-fusion
|
|
16
|
+
channels:
|
|
17
|
+
- conda-forge
|
|
18
|
+
dependencies:
|
|
19
|
+
- python=3.12
|
|
20
|
+
- pip
|
|
21
|
+
- numpy
|
|
22
|
+
- scipy
|
|
23
|
+
- matplotlib
|
|
24
|
+
- ipykernel
|
|
25
|
+
- mypy
|
|
26
|
+
- pip:
|
|
27
|
+
- -e .[test,lint]
|