chemunited-sim 0.0.2__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.
Files changed (92) hide show
  1. chemunited_sim-0.0.2/.github/workflows/pre-commit.yml +38 -0
  2. chemunited_sim-0.0.2/.github/workflows/publish.yml +141 -0
  3. chemunited_sim-0.0.2/.github/workflows/security.yml +37 -0
  4. chemunited_sim-0.0.2/.gitignore +221 -0
  5. chemunited_sim-0.0.2/.pre-commit-config.yaml +23 -0
  6. chemunited_sim-0.0.2/LICENSE +21 -0
  7. chemunited_sim-0.0.2/PKG-INFO +45 -0
  8. chemunited_sim-0.0.2/README.md +136 -0
  9. chemunited_sim-0.0.2/chemunited_sim_architecture.svg +165 -0
  10. chemunited_sim-0.0.2/docs/SDD.drawio +157 -0
  11. chemunited_sim-0.0.2/docs/api-reference.md +177 -0
  12. chemunited_sim-0.0.2/docs/architecture.md +254 -0
  13. chemunited_sim-0.0.2/docs/examples.md +44 -0
  14. chemunited_sim-0.0.2/docs/index.md +39 -0
  15. chemunited_sim-0.0.2/docs/mcp-tools.md +47 -0
  16. chemunited_sim-0.0.2/docs/quickstart.md +121 -0
  17. chemunited_sim-0.0.2/docs/recording.md +91 -0
  18. chemunited_sim-0.0.2/examples/README.md +131 -0
  19. chemunited_sim-0.0.2/examples/full_platform.py +726 -0
  20. chemunited_sim-0.0.2/examples/full_platform_diagram.drawio +182 -0
  21. chemunited_sim-0.0.2/examples/full_platform_flow_diagram.svg +212 -0
  22. chemunited_sim-0.0.2/pyproject.toml +81 -0
  23. chemunited_sim-0.0.2/src/chemunited_sim/__init__.py +4 -0
  24. chemunited_sim-0.0.2/src/chemunited_sim/adapter/__init__.py +17 -0
  25. chemunited_sim-0.0.2/src/chemunited_sim/adapter/compilers.py +545 -0
  26. chemunited_sim-0.0.2/src/chemunited_sim/adapter/graph.py +293 -0
  27. chemunited_sim-0.0.2/src/chemunited_sim/adapter/models.py +141 -0
  28. chemunited_sim-0.0.2/src/chemunited_sim/cli/__init__.py +1 -0
  29. chemunited_sim-0.0.2/src/chemunited_sim/cli/builder.py +204 -0
  30. chemunited_sim-0.0.2/src/chemunited_sim/cli/clock.py +25 -0
  31. chemunited_sim-0.0.2/src/chemunited_sim/cli/loader.py +214 -0
  32. chemunited_sim-0.0.2/src/chemunited_sim/cli/main.py +124 -0
  33. chemunited_sim-0.0.2/src/chemunited_sim/cli/server.py +712 -0
  34. chemunited_sim-0.0.2/src/chemunited_sim/cli/sim_client.py +254 -0
  35. chemunited_sim-0.0.2/src/chemunited_sim/cli/tray.py +157 -0
  36. chemunited_sim-0.0.2/src/chemunited_sim/common/__init__.py +1 -0
  37. chemunited_sim-0.0.2/src/chemunited_sim/common/constant.py +69 -0
  38. chemunited_sim-0.0.2/src/chemunited_sim/common/edges.py +18 -0
  39. chemunited_sim-0.0.2/src/chemunited_sim/hydraulics/__init__.py +4 -0
  40. chemunited_sim-0.0.2/src/chemunited_sim/hydraulics/models.py +40 -0
  41. chemunited_sim-0.0.2/src/chemunited_sim/hydraulics/solver.py +242 -0
  42. chemunited_sim-0.0.2/src/chemunited_sim/inventory/__init__.py +19 -0
  43. chemunited_sim-0.0.2/src/chemunited_sim/inventory/engine.py +576 -0
  44. chemunited_sim-0.0.2/src/chemunited_sim/inventory/initialiser.py +81 -0
  45. chemunited_sim-0.0.2/src/chemunited_sim/inventory/models.py +59 -0
  46. chemunited_sim-0.0.2/src/chemunited_sim/inventory/port_map.py +167 -0
  47. chemunited_sim-0.0.2/src/chemunited_sim/inventory/source_map.py +88 -0
  48. chemunited_sim-0.0.2/src/chemunited_sim/mcp/__init__.py +30 -0
  49. chemunited_sim-0.0.2/src/chemunited_sim/mcp/tools.py +230 -0
  50. chemunited_sim-0.0.2/src/chemunited_sim/reactions/__init__.py +20 -0
  51. chemunited_sim-0.0.2/src/chemunited_sim/reactions/engine.py +90 -0
  52. chemunited_sim-0.0.2/src/chemunited_sim/reactions/models.py +229 -0
  53. chemunited_sim-0.0.2/src/chemunited_sim/recorder/__init__.py +12 -0
  54. chemunited_sim-0.0.2/src/chemunited_sim/recorder/cells.py +75 -0
  55. chemunited_sim-0.0.2/src/chemunited_sim/recorder/models.py +32 -0
  56. chemunited_sim-0.0.2/src/chemunited_sim/recorder/schema.py +198 -0
  57. chemunited_sim-0.0.2/src/chemunited_sim/recorder/writer.py +386 -0
  58. chemunited_sim-0.0.2/src/chemunited_sim/transport/__init__.py +12 -0
  59. chemunited_sim-0.0.2/src/chemunited_sim/transport/engine.py +698 -0
  60. chemunited_sim-0.0.2/src/chemunited_sim/transport/initialiser.py +62 -0
  61. chemunited_sim-0.0.2/src/chemunited_sim/transport/junction.py +71 -0
  62. chemunited_sim-0.0.2/src/chemunited_sim/transport/models.py +93 -0
  63. chemunited_sim-0.0.2/src/chemunited_sim/visualization/__init__.py +33 -0
  64. chemunited_sim-0.0.2/src/chemunited_sim/visualization/dashboard.py +2414 -0
  65. chemunited_sim-0.0.2/src/chemunited_sim/visualization/pyvis_export.py +471 -0
  66. chemunited_sim-0.0.2/src/chemunited_sim/visualization/query.py +190 -0
  67. chemunited_sim-0.0.2/src/chemunited_sim/worker/__init__.py +6 -0
  68. chemunited_sim-0.0.2/src/chemunited_sim/worker/config.py +30 -0
  69. chemunited_sim-0.0.2/src/chemunited_sim/worker/runner.py +781 -0
  70. chemunited_sim-0.0.2/tests/__init__.py +0 -0
  71. chemunited_sim-0.0.2/tests/flow_platform/draw/setup.py +140 -0
  72. chemunited_sim-0.0.2/tests/flow_platform/main.py +0 -0
  73. chemunited_sim-0.0.2/tests/flow_platform/protocols/__init__.py +5 -0
  74. chemunited_sim-0.0.2/tests/flow_platform/protocols/parameters.py +11 -0
  75. chemunited_sim-0.0.2/tests/flow_platform/protocols/simulate.py +79 -0
  76. chemunited_sim-0.0.2/tests/flow_platform/protocols_historic/run_001.json +4 -0
  77. chemunited_sim-0.0.2/tests/test_adapter_compilers.py +192 -0
  78. chemunited_sim-0.0.2/tests/test_cli.py +20 -0
  79. chemunited_sim-0.0.2/tests/test_flow_platform.py +366 -0
  80. chemunited_sim-0.0.2/tests/test_flow_platform_temperature.py +342 -0
  81. chemunited_sim-0.0.2/tests/test_hard_closed_edges.py +176 -0
  82. chemunited_sim-0.0.2/tests/test_hydraulics.py +155 -0
  83. chemunited_sim-0.0.2/tests/test_inventory.py +301 -0
  84. chemunited_sim-0.0.2/tests/test_loader_protocol_reload.py +96 -0
  85. chemunited_sim-0.0.2/tests/test_mcp.py +312 -0
  86. chemunited_sim-0.0.2/tests/test_reactions.py +150 -0
  87. chemunited_sim-0.0.2/tests/test_recorder.py +722 -0
  88. chemunited_sim-0.0.2/tests/test_sim_client.py +276 -0
  89. chemunited_sim-0.0.2/tests/test_transport.py +376 -0
  90. chemunited_sim-0.0.2/tests/test_tray.py +93 -0
  91. chemunited_sim-0.0.2/tests/test_visualization.py +616 -0
  92. chemunited_sim-0.0.2/tests/test_worker.py +568 -0
@@ -0,0 +1,38 @@
1
+ name: Pre-commit
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [main]
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ pre-commit:
13
+ name: Run pre-commit hooks
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - name: Check out repository
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Set up Python
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: "3.11"
24
+ cache: pip
25
+
26
+ - name: Cache pre-commit environments
27
+ uses: actions/cache@v4
28
+ with:
29
+ path: ~/.cache/pre-commit
30
+ key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
31
+
32
+ - name: Install package and pre-commit
33
+ run: |
34
+ python -m pip install --upgrade pip
35
+ python -m pip install -e ".[dev]"
36
+
37
+ - name: Run pre-commit
38
+ run: pre-commit run --all-files --show-diff-on-failure
@@ -0,0 +1,141 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ build:
13
+ name: Test and build distributions
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - name: Check out repository
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Set up Python
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: "3.11"
24
+ cache: pip
25
+
26
+ - name: Install package and build tools
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ python -m pip install -e ".[dev]"
30
+ python -m pip install build twine
31
+
32
+ - name: Verify tag matches package version
33
+ run: |
34
+ python - <<'PY'
35
+ import os
36
+ import tomllib
37
+ from pathlib import Path
38
+
39
+ tag = os.environ["GITHUB_REF_NAME"]
40
+ if not tag.startswith("v"):
41
+ raise SystemExit(f"Expected a v-prefixed release tag, got {tag!r}")
42
+
43
+ tag_version = tag[1:]
44
+ with Path("pyproject.toml").open("rb") as pyproject:
45
+ package_version = tomllib.load(pyproject)["project"]["version"]
46
+
47
+ if tag_version != package_version:
48
+ raise SystemExit(
49
+ f"Release tag {tag!r} does not match pyproject.toml version "
50
+ f"{package_version!r}"
51
+ )
52
+ PY
53
+
54
+ - name: Run tests
55
+ run: python -m pytest --tb=short -q
56
+
57
+ - name: Build distributions
58
+ run: python -m build
59
+
60
+ - name: Check distribution metadata
61
+ run: python -m twine check dist/*
62
+
63
+ - name: Upload distributions
64
+ uses: actions/upload-artifact@v4
65
+ with:
66
+ name: python-package-distributions
67
+ path: dist/
68
+ if-no-files-found: error
69
+
70
+ github-release:
71
+ name: Create GitHub Release
72
+ needs: build
73
+ runs-on: ubuntu-latest
74
+ permissions:
75
+ contents: write
76
+
77
+ steps:
78
+ - name: Download distributions
79
+ uses: actions/download-artifact@v4
80
+ with:
81
+ name: python-package-distributions
82
+ path: dist/
83
+
84
+ - name: Create release and upload distributions
85
+ env:
86
+ GH_TOKEN: ${{ github.token }}
87
+ run: |
88
+ if gh release view "$GITHUB_REF_NAME" --repo "${{ github.repository }}" >/dev/null 2>&1; then
89
+ gh release upload "$GITHUB_REF_NAME" dist/* \
90
+ --repo "${{ github.repository }}" \
91
+ --clobber
92
+ else
93
+ gh release create "$GITHUB_REF_NAME" dist/* \
94
+ --repo "${{ github.repository }}" \
95
+ --title "$GITHUB_REF_NAME" \
96
+ --generate-notes \
97
+ --verify-tag
98
+ fi
99
+
100
+ publish-testpypi:
101
+ name: Publish to TestPyPI
102
+ needs: github-release
103
+ runs-on: ubuntu-latest
104
+ environment: testpypi
105
+ permissions:
106
+ contents: read
107
+ id-token: write
108
+
109
+ steps:
110
+ - name: Download distributions
111
+ uses: actions/download-artifact@v4
112
+ with:
113
+ name: python-package-distributions
114
+ path: dist/
115
+
116
+ - name: Publish distributions to TestPyPI
117
+ uses: pypa/gh-action-pypi-publish@release/v1
118
+ with:
119
+ repository-url: https://test.pypi.org/legacy/
120
+ skip-existing: true
121
+
122
+ publish-pypi:
123
+ name: Publish to PyPI
124
+ needs: publish-testpypi
125
+ runs-on: ubuntu-latest
126
+ environment: pypi
127
+ permissions:
128
+ contents: read
129
+ id-token: write
130
+
131
+ steps:
132
+ - name: Download distributions
133
+ uses: actions/download-artifact@v4
134
+ with:
135
+ name: python-package-distributions
136
+ path: dist/
137
+
138
+ - name: Publish distributions to PyPI
139
+ uses: pypa/gh-action-pypi-publish@release/v1
140
+ with:
141
+ skip-existing: true
@@ -0,0 +1,37 @@
1
+ name: Security Analysis
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [main]
7
+ schedule:
8
+ - cron: "17 3 * * 1"
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ package-security:
15
+ name: Dependency and static security scan
16
+ runs-on: ubuntu-latest
17
+
18
+ steps:
19
+ - name: Check out repository
20
+ uses: actions/checkout@v4
21
+
22
+ - name: Set up Python
23
+ uses: actions/setup-python@v5
24
+ with:
25
+ python-version: "3.11"
26
+ cache: pip
27
+
28
+ - name: Install package and security tools
29
+ run: |
30
+ python -m pip install --upgrade pip setuptools
31
+ python -m pip install -e ".[dev]" pip-audit bandit[toml]
32
+
33
+ - name: Audit Python dependencies
34
+ run: pip-audit --skip-editable
35
+
36
+ - name: Run Bandit
37
+ run: bandit -c pyproject.toml -r src/chemunited_sim
@@ -0,0 +1,221 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
208
+
209
+ # AI files
210
+ .claude
211
+ CLAUDE.md
212
+ AGENTS.md
213
+
214
+ # examples
215
+ examples/simulation
216
+ simulations/
217
+
218
+ # pre-commit
219
+ .pre-commit-cache*
220
+ .tmp*
221
+ tests/flow_platform/log/
@@ -0,0 +1,23 @@
1
+ repos:
2
+ - repo: local
3
+ hooks:
4
+ - id: ruff-check
5
+ name: ruff check
6
+ entry: ruff check --fix --no-cache
7
+ language: system
8
+ types: [python]
9
+ - id: black
10
+ name: black
11
+ entry: black --no-cache
12
+ language: system
13
+ types: [python]
14
+ - id: mypy
15
+ name: mypy
16
+ entry: mypy
17
+ language: system
18
+ pass_filenames: false
19
+ - id: pytest
20
+ name: pytest
21
+ entry: python -m pytest
22
+ language: system
23
+ pass_filenames: false
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Automated Chemistry @ Max Plank Institute of Colloids and Interfaces
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,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: chemunited-sim
3
+ Version: 0.0.2
4
+ Summary: Dynamic simulation engine for fluidic automation platforms built on chemunited-core.
5
+ Author: Samuel Vitor Saraiva
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Automated Chemistry @ Max Plank Institute of Colloids and Interfaces
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ License-File: LICENSE
28
+ Requires-Python: >=3.11
29
+ Requires-Dist: chemunited-core>=0.0.4
30
+ Requires-Dist: chemunited-workflow>=0.0.4
31
+ Requires-Dist: fastapi>=0.115
32
+ Requires-Dist: mcp[cli]>=1.23
33
+ Requires-Dist: pyvis>=0.3.2
34
+ Requires-Dist: scipy>=1.12
35
+ Requires-Dist: uvicorn[standard]>=0.29
36
+ Provides-Extra: dev
37
+ Requires-Dist: black>=25.1.0; extra == 'dev'
38
+ Requires-Dist: mypy>=1.19.1; extra == 'dev'
39
+ Requires-Dist: pre-commit>=4.0; extra == 'dev'
40
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
41
+ Requires-Dist: pytest>=8.0; extra == 'dev'
42
+ Requires-Dist: ruff>=0.15.7; extra == 'dev'
43
+ Provides-Extra: tray
44
+ Requires-Dist: pillow>=10; extra == 'tray'
45
+ Requires-Dist: pystray>=0.19; extra == 'tray'
@@ -0,0 +1,136 @@
1
+ # chemunited-sim
2
+
3
+ `chemunited-sim` is a dynamic simulation engine for fluidic automation
4
+ platforms described with `chemunited-core` components and connections.
5
+
6
+ The package compiles a ChemUnited platform into a flat hydraulic graph, solves
7
+ steady-state pressures and flows, moves liquid/gas pockets through transport
8
+ edges, updates vessel inventories, applies simple reaction models, and records
9
+ simulation state to SQLite.
10
+
11
+ It also ships a self-contained **simulation server**: a long-running FastAPI
12
+ process that loads a project at runtime, runs it at CPU speed (mode 1 —
13
+ workflow simulation) or wall-clock pace (mode 2 — real-time shadow), and
14
+ exposes results as a WAL-mode SQLite database that a GUI can read live.
15
+
16
+ ## Install
17
+
18
+ From the repository root:
19
+
20
+ ```powershell
21
+ .\.venv\Scripts\python.exe -m pip install -e .
22
+ ```
23
+
24
+ For development tools:
25
+
26
+ ```powershell
27
+ .\.venv\Scripts\python.exe -m pip install -e ".[dev]"
28
+ ```
29
+
30
+ `chemunited-core` and `chemunited-workflow` are installed directly from GitHub
31
+ through `pyproject.toml`.
32
+
33
+ ## Simulation server
34
+
35
+ ```powershell
36
+ chemunited-sim [project] [--port 1472] [--db ./simulations/] [--with-mcp]
37
+ ```
38
+
39
+ Starts a FastAPI server at `http://localhost:<port>`. OpenAPI docs at
40
+ `http://localhost:<port>/docs`.
41
+
42
+ | Argument | Default | Description |
43
+ |---|---|---|
44
+ | `project` | — | Path to a project folder or `.chemunited` ZIP. Omit to start in `NO_PROJECT` state. |
45
+ | `--port` | `1472` | Listening port |
46
+ | `--db` | `./simulations/` | Directory where `.db` files are written |
47
+ | `--with-mcp` | off | Mount an MCP endpoint at `/mcp` on the same host/port — see [docs/mcp-tools.md](docs/mcp-tools.md) |
48
+
49
+ ### REST API
50
+
51
+ | Method | Endpoint | Description |
52
+ |---|---|---|
53
+ | `POST` | `/project/load` | Load or replace a project; compile its hydraulic graph |
54
+ | `GET` | `/project` | Info about the currently loaded project |
55
+ | `GET` | `/status` | Server state: `sim_status`, `current_t`, active `SimConfig` |
56
+ | `POST` | `/simulation/start` | Start a simulation run (`execution_id`, `dt`, `t_end`, `real_time`) |
57
+ | `POST` | `/simulation/stop` | Abort the running simulation |
58
+ | `POST` | `/simulation/command` | Enqueue a component command (mode 2 only) |
59
+ | `GET` | `/simulation/db` | Path of the active or last `.db` file |
60
+ | `GET` | `/simulation/visualization` | Interactive pyvis graph for the latest recorded snapshot |
61
+
62
+ Open `http://127.0.0.1:1472/simulation/visualization` in a browser to inspect
63
+ the latest available simulation snapshot.
64
+
65
+ ### MCP server
66
+
67
+ Pass `--with-mcp` to also mount a streamable-HTTP MCP endpoint at `/mcp` on
68
+ the same host/port, so an LLM agent can load a project, run a simulation, and
69
+ pull back structured pressure/temperature/flow/content results to judge
70
+ whether a process is feasible — without needing the REST API or the raw
71
+ `.db` file. No authentication (local-only, matching the REST API's
72
+ `127.0.0.1` default). See [docs/mcp-tools.md](docs/mcp-tools.md) for the full
73
+ tool reference.
74
+
75
+ ### Server state machine
76
+
77
+ ```
78
+ NO_PROJECT ── POST /project/load ──► IDLE
79
+ IDLE ── POST /project/load ──► IDLE (replaces project)
80
+ IDLE ── POST /simulation/start ► RUNNING
81
+ RUNNING ── POST /simulation/stop ─► IDLE
82
+ RUNNING ── auto-complete ─────────► IDLE
83
+ RUNNING ── POST /project/load ────► 409 (rejected)
84
+ ```
85
+
86
+ ### Mode 1 — Workflow simulation (`real_time=False`)
87
+
88
+ The protocol runs in-process via a `SimClient` that busy-waits on `SimClock`
89
+ instead of `time.sleep()`. Commands generated by the protocol are enqueued and
90
+ applied by the Worker Thread between physics steps. The simulation runs at CPU
91
+ speed — far faster than real time.
92
+
93
+ ### Mode 2 — Real-time simulation (`real_time=True`)
94
+
95
+ No workflow thread is spawned. The Worker Thread runs at wall-clock pace.
96
+ Commands arrive at `POST /simulation/command` from the work-server as it
97
+ executes them on real hardware.
98
+
99
+ ## Programmatic usage
100
+
101
+ ```python
102
+ from chemunited_sim.adapter import compile_graph
103
+ from chemunited_sim.worker import SimConfig, Worker
104
+
105
+ graph = compile_graph(components, edges)
106
+ worker = Worker(graph, components, SimConfig(dt=0.1, t_end=10.0))
107
+ worker.run()
108
+
109
+ print(worker.t)
110
+ print(worker.hyd_state.pressures)
111
+ print(worker.hyd_state.flows)
112
+ ```
113
+
114
+ See [docs/quickstart.md](docs/quickstart.md) for a complete runnable example.
115
+
116
+ ## Documentation
117
+
118
+ | Page | Purpose |
119
+ |---|---|
120
+ | [docs/index.md](docs/index.md) | Package overview and documentation map |
121
+ | [docs/quickstart.md](docs/quickstart.md) | Installation and a runnable first simulation |
122
+ | [docs/architecture.md](docs/architecture.md) | Simulation loop, graph model, and module boundaries |
123
+ | [docs/api-reference.md](docs/api-reference.md) | Public import paths and API summary |
124
+ | [docs/recording.md](docs/recording.md) | SQLite recorder schema and usage |
125
+ | [docs/examples.md](docs/examples.md) | Existing examples and what they demonstrate |
126
+ | [docs/mcp-tools.md](docs/mcp-tools.md) | MCP server tool reference for LLM agents |
127
+
128
+ ## Development
129
+
130
+ ```powershell
131
+ .\.venv\Scripts\pytest.exe
132
+ pre-commit run --all-files
133
+ ```
134
+
135
+ The test suite covers the worker loop, BPR stabilisation, transport recording,
136
+ and SQLite recorder behavior.