tep-studio 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.
- tep_studio-0.1.0/LICENSE +52 -0
- tep_studio-0.1.0/MANIFEST.in +8 -0
- tep_studio-0.1.0/PKG-INFO +236 -0
- tep_studio-0.1.0/README.md +143 -0
- tep_studio-0.1.0/example.doc +479 -0
- tep_studio-0.1.0/pyproject.toml +90 -0
- tep_studio-0.1.0/setup.cfg +4 -0
- tep_studio-0.1.0/setup.py +3 -0
- tep_studio-0.1.0/src/tep_studio/__init__.py +141 -0
- tep_studio-0.1.0/src/tep_studio/analysis.py +49 -0
- tep_studio-0.1.0/src/tep_studio/cli.py +207 -0
- tep_studio-0.1.0/src/tep_studio/control/__init__.py +66 -0
- tep_studio-0.1.0/src/tep_studio/control/config.py +100 -0
- tep_studio-0.1.0/src/tep_studio/control/controller.py +326 -0
- tep_studio-0.1.0/src/tep_studio/control/examples/__init__.py +1 -0
- tep_studio-0.1.0/src/tep_studio/control/examples/custom_controller.py +58 -0
- tep_studio-0.1.0/src/tep_studio/control/examples/disturbance_scenario.py +44 -0
- tep_studio-0.1.0/src/tep_studio/control/examples/mv_step_test.py +32 -0
- tep_studio-0.1.0/src/tep_studio/control/examples/ricker_mode1_closed_loop.py +52 -0
- tep_studio-0.1.0/src/tep_studio/control/experiment.py +89 -0
- tep_studio-0.1.0/src/tep_studio/control/figures.py +209 -0
- tep_studio-0.1.0/src/tep_studio/control/loops.py +137 -0
- tep_studio-0.1.0/src/tep_studio/control/metrics.py +71 -0
- tep_studio-0.1.0/src/tep_studio/control/pi.py +106 -0
- tep_studio-0.1.0/src/tep_studio/control/registry.py +94 -0
- tep_studio-0.1.0/src/tep_studio/control/runner.py +162 -0
- tep_studio-0.1.0/src/tep_studio/control/tests/__init__.py +1 -0
- tep_studio-0.1.0/src/tep_studio/control/tests/test_closed_loop.py +85 -0
- tep_studio-0.1.0/src/tep_studio/control/tests/test_disturbances.py +48 -0
- tep_studio-0.1.0/src/tep_studio/control/tests/test_overrides.py +93 -0
- tep_studio-0.1.0/src/tep_studio/control/tests/test_pi.py +57 -0
- tep_studio-0.1.0/src/tep_studio/control/tests/test_registry.py +60 -0
- tep_studio-0.1.0/src/tep_studio/control/tests/test_setpoint_schedule.py +46 -0
- tep_studio-0.1.0/src/tep_studio/control/tests/test_views_and_records.py +60 -0
- tep_studio-0.1.0/src/tep_studio/control/views.py +42 -0
- tep_studio-0.1.0/src/tep_studio/simulation/__init__.py +16 -0
- tep_studio-0.1.0/src/tep_studio/simulation/_cffi_build.py +258 -0
- tep_studio-0.1.0/src/tep_studio/simulation/core.py +327 -0
- tep_studio-0.1.0/src/tep_studio/simulation/dataset.py +77 -0
- tep_studio-0.1.0/src/tep_studio/simulation/examples/__init__.py +2 -0
- tep_studio-0.1.0/src/tep_studio/simulation/examples/r12_open_loop.py +26 -0
- tep_studio-0.1.0/src/tep_studio/simulation/examples/rl_training.py +65 -0
- tep_studio-0.1.0/src/tep_studio/simulation/gym_env.py +96 -0
- tep_studio-0.1.0/src/tep_studio/simulation/native.py +246 -0
- tep_studio-0.1.0/src/tep_studio/simulation/optimization.py +136 -0
- tep_studio-0.1.0/src/tep_studio/simulation/schema.py +503 -0
- tep_studio-0.1.0/src/tep_studio/simulation/tests/__init__.py +2 -0
- tep_studio-0.1.0/src/tep_studio/simulation/tests/test_gym_env_ext.py +34 -0
- tep_studio-0.1.0/src/tep_studio/simulation/tests/test_integrators.py +70 -0
- tep_studio-0.1.0/src/tep_studio/simulation/tests/test_linearize.py +49 -0
- tep_studio-0.1.0/src/tep_studio/simulation/tests/test_tep_studio.py +168 -0
- tep_studio-0.1.0/src/tep_studio/simulation/tests/test_validation.py +134 -0
- tep_studio-0.1.0/src/tep_studio/simulation/validation/__init__.py +13 -0
- tep_studio-0.1.0/src/tep_studio/simulation/validation/__main__.py +6 -0
- tep_studio-0.1.0/src/tep_studio/simulation/validation/artifacts.py +49 -0
- tep_studio-0.1.0/src/tep_studio/simulation/validation/base_case.py +136 -0
- tep_studio-0.1.0/src/tep_studio/simulation/validation/cli.py +54 -0
- tep_studio-0.1.0/src/tep_studio/simulation/validation/figures.py +343 -0
- tep_studio-0.1.0/src/tep_studio/simulation/validation/mat_states.py +264 -0
- tep_studio-0.1.0/src/tep_studio/simulation/validation/metrics.py +61 -0
- tep_studio-0.1.0/src/tep_studio/simulation/validation/references.py +81 -0
- tep_studio-0.1.0/src/tep_studio/simulation/validation/report.py +195 -0
- tep_studio-0.1.0/src/tep_studio/simulation/validation/runner.py +321 -0
- tep_studio-0.1.0/src/tep_studio/simulation/validation/scenarios.py +91 -0
- tep_studio-0.1.0/src/tep_studio/simulation/validation/steady_state.py +650 -0
- tep_studio-0.1.0/src/tep_studio/tests/__init__.py +0 -0
- tep_studio-0.1.0/src/tep_studio/tests/test_cli.py +37 -0
- tep_studio-0.1.0/src/tep_studio/tests/test_package_api.py +56 -0
- tep_studio-0.1.0/src/tep_studio/ui/__init__.py +47 -0
- tep_studio-0.1.0/src/tep_studio/ui/__main__.py +23 -0
- tep_studio-0.1.0/src/tep_studio/ui/app.py +52 -0
- tep_studio-0.1.0/src/tep_studio/ui/callbacks.py +370 -0
- tep_studio-0.1.0/src/tep_studio/ui/config.py +236 -0
- tep_studio-0.1.0/src/tep_studio/ui/figures.py +147 -0
- tep_studio-0.1.0/src/tep_studio/ui/layout.py +187 -0
- tep_studio-0.1.0/src/tep_studio/ui/results.py +64 -0
- tep_studio-0.1.0/src/tep_studio/ui/service.py +335 -0
- tep_studio-0.1.0/src/tep_studio/ui/store.py +66 -0
- tep_studio-0.1.0/src/tep_studio/ui/tests/__init__.py +1 -0
- tep_studio-0.1.0/src/tep_studio/ui/tests/test_app_smoke.py +102 -0
- tep_studio-0.1.0/src/tep_studio/ui/tests/test_config_roundtrip.py +74 -0
- tep_studio-0.1.0/src/tep_studio/ui/tests/test_figures.py +62 -0
- tep_studio-0.1.0/src/tep_studio/ui/tests/test_results_store.py +71 -0
- tep_studio-0.1.0/src/tep_studio/ui/tests/test_service.py +86 -0
- tep_studio-0.1.0/src/tep_studio/ui/widgets.py +90 -0
- tep_studio-0.1.0/src/tep_studio.egg-info/PKG-INFO +236 -0
- tep_studio-0.1.0/src/tep_studio.egg-info/SOURCES.txt +95 -0
- tep_studio-0.1.0/src/tep_studio.egg-info/dependency_links.txt +1 -0
- tep_studio-0.1.0/src/tep_studio.egg-info/entry_points.txt +3 -0
- tep_studio-0.1.0/src/tep_studio.egg-info/requires.txt +16 -0
- tep_studio-0.1.0/src/tep_studio.egg-info/top_level.txt +1 -0
- tep_studio-0.1.0/temexd_mod/Mode1SkogeInit.mat +0 -0
- tep_studio-0.1.0/temexd_mod/Mode1xInitial.mat +0 -0
- tep_studio-0.1.0/temexd_mod/Mode3xInitial.mat +0 -0
- tep_studio-0.1.0/temexd_mod/README.md +17 -0
- tep_studio-0.1.0/temexd_mod/temexd_mod.c +3973 -0
- tep_studio-0.1.0/temexd_mod/teprob_mod.h +253 -0
tep_studio-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Khalid
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
17
|
+
may be used to endorse or promote products derived from this software without
|
|
18
|
+
specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
21
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
24
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
25
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
26
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
27
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
29
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
================================================================================
|
|
33
|
+
Bundled third-party code
|
|
34
|
+
================================================================================
|
|
35
|
+
|
|
36
|
+
This package bundles the numerical model of the modified Tennessee Eastman
|
|
37
|
+
Process in `temexd_mod/temexd_mod.c` and `temexd_mod/teprob_mod.h`. That model is
|
|
38
|
+
the work of third parties and is redistributed here for research and educational
|
|
39
|
+
use, with its original source headers retained:
|
|
40
|
+
|
|
41
|
+
- Original Tennessee Eastman process control test problem by James J. Downs and
|
|
42
|
+
Ernest F. Vogel (Eastman Chemical Company), "A Plant-Wide Industrial Process
|
|
43
|
+
Control Problem", Computers & Chemical Engineering 17(3), 1993.
|
|
44
|
+
|
|
45
|
+
- Revised C model ("temexd_mod") by Andreas Bathelt and N. Lawrence Ricker, with
|
|
46
|
+
Mohieddine Jelali, "Revision of the Tennessee Eastman Process Model",
|
|
47
|
+
IFAC-PapersOnLine (ADCHEM) 48(8), 2015.
|
|
48
|
+
|
|
49
|
+
The BSD 3-Clause license above covers this Python package (the schema-driven
|
|
50
|
+
wrapper, control, interface, dataset, validation, and tooling code). It does not
|
|
51
|
+
purport to grant rights in the bundled upstream model beyond those provided by its
|
|
52
|
+
authors. Retain these attributions in any redistribution.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# The native extension is compiled from temexd_mod/ at build time (see
|
|
2
|
+
# src/tep_studio/simulation/_cffi_build.py), so the sdist must ship those C sources;
|
|
3
|
+
# without them `pip install` from the sdist (no prebuilt wheel) cannot build.
|
|
4
|
+
graft temexd_mod
|
|
5
|
+
# Validation reference data (read by the validation suite from a source checkout).
|
|
6
|
+
include example.doc
|
|
7
|
+
# Trim build noise from the sdist.
|
|
8
|
+
global-exclude *.so *.pyc __pycache__/*
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tep-studio
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Schema-driven Python simulator for the modified Tennessee Eastman Process.
|
|
5
|
+
Author-email: Khalid <wa3id.km@gmail.com>
|
|
6
|
+
License: BSD 3-Clause License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026, Khalid
|
|
9
|
+
All rights reserved.
|
|
10
|
+
|
|
11
|
+
Redistribution and use in source and binary forms, with or without
|
|
12
|
+
modification, are permitted provided that the following conditions are met:
|
|
13
|
+
|
|
14
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
15
|
+
list of conditions and the following disclaimer.
|
|
16
|
+
|
|
17
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
18
|
+
this list of conditions and the following disclaimer in the documentation
|
|
19
|
+
and/or other materials provided with the distribution.
|
|
20
|
+
|
|
21
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
22
|
+
may be used to endorse or promote products derived from this software without
|
|
23
|
+
specific prior written permission.
|
|
24
|
+
|
|
25
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
26
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
27
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
28
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
29
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
30
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
31
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
32
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
33
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
34
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
================================================================================
|
|
38
|
+
Bundled third-party code
|
|
39
|
+
================================================================================
|
|
40
|
+
|
|
41
|
+
This package bundles the numerical model of the modified Tennessee Eastman
|
|
42
|
+
Process in `temexd_mod/temexd_mod.c` and `temexd_mod/teprob_mod.h`. That model is
|
|
43
|
+
the work of third parties and is redistributed here for research and educational
|
|
44
|
+
use, with its original source headers retained:
|
|
45
|
+
|
|
46
|
+
- Original Tennessee Eastman process control test problem by James J. Downs and
|
|
47
|
+
Ernest F. Vogel (Eastman Chemical Company), "A Plant-Wide Industrial Process
|
|
48
|
+
Control Problem", Computers & Chemical Engineering 17(3), 1993.
|
|
49
|
+
|
|
50
|
+
- Revised C model ("temexd_mod") by Andreas Bathelt and N. Lawrence Ricker, with
|
|
51
|
+
Mohieddine Jelali, "Revision of the Tennessee Eastman Process Model",
|
|
52
|
+
IFAC-PapersOnLine (ADCHEM) 48(8), 2015.
|
|
53
|
+
|
|
54
|
+
The BSD 3-Clause license above covers this Python package (the schema-driven
|
|
55
|
+
wrapper, control, interface, dataset, validation, and tooling code). It does not
|
|
56
|
+
purport to grant rights in the bundled upstream model beyond those provided by its
|
|
57
|
+
authors. Retain these attributions in any redistribution.
|
|
58
|
+
|
|
59
|
+
Project-URL: Homepage, https://github.com/khalidlabs/tep-studio
|
|
60
|
+
Project-URL: Documentation, https://khalidlabs.com/tep-studio/
|
|
61
|
+
Project-URL: Source, https://github.com/khalidlabs/tep-studio
|
|
62
|
+
Project-URL: Issues, https://github.com/khalidlabs/tep-studio/issues
|
|
63
|
+
Keywords: tennessee-eastman,process-control,chemical-engineering,reinforcement-learning,gymnasium,simulation,control-systems,benchmark
|
|
64
|
+
Classifier: Development Status :: 4 - Beta
|
|
65
|
+
Classifier: Intended Audience :: Science/Research
|
|
66
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
67
|
+
Classifier: Operating System :: OS Independent
|
|
68
|
+
Classifier: Programming Language :: Python :: 3
|
|
69
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
70
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
71
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
72
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
73
|
+
Classifier: Topic :: Scientific/Engineering
|
|
74
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
75
|
+
Requires-Python: >=3.10
|
|
76
|
+
Description-Content-Type: text/markdown
|
|
77
|
+
License-File: LICENSE
|
|
78
|
+
Requires-Dist: cffi>=1.15
|
|
79
|
+
Requires-Dist: numpy>=1.24
|
|
80
|
+
Requires-Dist: scipy>=1.10
|
|
81
|
+
Requires-Dist: pandas>=1.5
|
|
82
|
+
Requires-Dist: gymnasium>=0.29
|
|
83
|
+
Requires-Dist: matplotlib>=3.6
|
|
84
|
+
Provides-Extra: docs
|
|
85
|
+
Requires-Dist: mkdocs>=1.6; extra == "docs"
|
|
86
|
+
Requires-Dist: mkdocs-material>=9.5; extra == "docs"
|
|
87
|
+
Provides-Extra: ui
|
|
88
|
+
Requires-Dist: dash[diskcache]>=2.16; extra == "ui"
|
|
89
|
+
Requires-Dist: plotly>=5.9; extra == "ui"
|
|
90
|
+
Requires-Dist: pyarrow>=14; extra == "ui"
|
|
91
|
+
Requires-Dist: comm>=0.2; extra == "ui"
|
|
92
|
+
Dynamic: license-file
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
title: TEP Studio
|
|
96
|
+
emoji: 🏭
|
|
97
|
+
colorFrom: blue
|
|
98
|
+
colorTo: indigo
|
|
99
|
+
sdk: docker
|
|
100
|
+
app_port: 7860
|
|
101
|
+
pinned: false
|
|
102
|
+
short_description: Interactive Tennessee Eastman Process simulation studio (Dash + Plotly)
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
# TEP Studio
|
|
106
|
+
|
|
107
|
+
This repository contains a schema-driven Python implementation of the modified Tennessee Eastman Process in `temexd_mod`. Simulation code lives in `src/tep_studio/simulation/`; `src/tep_studio/__init__.py` re-exports the public API.
|
|
108
|
+
|
|
109
|
+
The Python package keeps the original `temexd_mod.c` equations as the numerical source of truth by compiling a native CFFI extension, then exposes process-aware Python contracts for:
|
|
110
|
+
|
|
111
|
+
- process-core use through `TennesseeEastmanProcess`
|
|
112
|
+
- Gymnasium RL/control interaction through `GymTEPEnv`
|
|
113
|
+
- causal trajectory datasets through `TrajectoryDataset`
|
|
114
|
+
- deterministic rollout and finite-difference optimization through `OptimizationAdapter`
|
|
115
|
+
- closed-loop decentralized control through `ClosedLoopSimulation` and `RickerMultiLoopController`
|
|
116
|
+
- an interactive Dash + Plotly interface for runs, step tests, and dataset generation (`tep_studio.ui`)
|
|
117
|
+
|
|
118
|
+
## Quickstart
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
pip install tep-studio # add [ui] for the web Simulation Studio
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
import tep_studio as tep
|
|
126
|
+
tep.quickstart() # short closed-loop smoke run
|
|
127
|
+
|
|
128
|
+
import gymnasium # a registered RL environment
|
|
129
|
+
env = gymnasium.make("TennesseeEastman-v0", horizon=24.0)
|
|
130
|
+
|
|
131
|
+
from tep_studio import ClosedLoopSimulation # the stabilized closed loop
|
|
132
|
+
result = ClosedLoopSimulation(horizon=24.0).run()
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Or from the terminal: `tep run --horizon 24 --idv idv_01@1.0`, `tep list disturbances`,
|
|
136
|
+
`tep ui`. See the [Cookbook](docs/cookbook.md) for task recipes.
|
|
137
|
+
|
|
138
|
+
## Build
|
|
139
|
+
|
|
140
|
+
Once published to PyPI, `pip install tep-studio` pulls a prebuilt wheel for
|
|
141
|
+
Linux, macOS, and Windows — no C compiler required. The instructions below are for
|
|
142
|
+
building from a source checkout, which compiles the native extension locally.
|
|
143
|
+
|
|
144
|
+
The build requires `setuptools>=68` (declared in `pyproject.toml`). The recommended
|
|
145
|
+
path is an editable install, which uses build isolation to provision the correct
|
|
146
|
+
build dependencies automatically:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
python3 -m pip install -e .
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
If your environment blocks build isolation (for example, an offline machine), first
|
|
153
|
+
ensure the build tools are current, then install without isolation:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
python3 -m pip install -U "setuptools>=68" wheel cffi
|
|
157
|
+
python3 -m pip install -e . --no-build-isolation
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
To build the native extension in place instead of installing, the same
|
|
161
|
+
`setuptools>=68` requirement applies (older setuptools mis-places the compiled
|
|
162
|
+
artifact under the `src/` layout):
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
python3 -m pip install -U "setuptools>=68"
|
|
166
|
+
python3 setup.py build_ext --inplace
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
The compiled `_tep_native` extension is platform-specific and is not tracked in
|
|
170
|
+
version control. After moving the repository to a new machine or operating system,
|
|
171
|
+
rebuild it with one of the commands above before importing the package.
|
|
172
|
+
|
|
173
|
+
## Smoke Test
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
PYTHONPATH=src python3 src/tep_studio/simulation/examples/r12_open_loop.py
|
|
177
|
+
PYTHONPATH=src python3 -m pytest -q
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The R12 open-loop example should terminate near 1.07 h with a high reactor pressure shutdown.
|
|
181
|
+
|
|
182
|
+
## Validation
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
PYTHONPATH=src python3 -m tep_studio.simulation.validation run --suite local
|
|
186
|
+
PYTHONPATH=src python3 -m tep_studio.simulation.validation run --suite steady_state
|
|
187
|
+
PYTHONPATH=src python3 -m tep_studio.simulation.validation run --suite mat_states
|
|
188
|
+
PYTHONPATH=src python3 -m tep_studio.simulation.validation run --suite all --solvers RK23 RK45
|
|
189
|
+
PYTHONPATH=src python3 -m tep_studio.simulation.validation figures
|
|
190
|
+
PYTHONPATH=src python3 -m tep_studio.simulation.validation report
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Validation artifacts are written under `src/tep_studio/simulation/validation_outputs/`. The steady-state suite exports the Ricker (1995) Table 2/3 references, compares the simulator base case against the reported Downs and Vogel steady state, and marks optimized modes 1-6 as reference-only unless their electronic 50-state vectors are supplied. The MAT-state suite evaluates the bundled Simulink `CSTATE` vectors for Mode 1, Mode 3, and Skogestad Mode 1 and writes paper-ready comparison tables and figures. Add `--download-external` to cache public reference metadata and files where available.
|
|
194
|
+
|
|
195
|
+
## Closed-Loop Control
|
|
196
|
+
|
|
197
|
+
The base-case plant is open-loop unstable and trips on high reactor pressure within a few hours. The `tep_studio.control` package adds the Ricker (1996) decentralized multiloop PI strategy, which stabilizes the plant for the full horizon:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
PYTHONPATH=src python3 src/tep_studio/control/examples/ricker_mode1_closed_loop.py
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
from tep_studio.control import ClosedLoopSimulation
|
|
205
|
+
|
|
206
|
+
result = ClosedLoopSimulation(control_interval=0.0005, horizon=48.0).run()
|
|
207
|
+
assert result.stabilized # ran the horizon without a shutdown
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
The controller is separate from the simulator core and consumes only published measurements (no plant-state leakage). It reproduces the loop pairings and gains from Ricker's runnable `MultiLoop_mode1.mdl`, initializes bumplessly from the Mode-1 state, and emits a reproducible experiment record. See `docs/control.md` for the loop structure, overrides, disturbance rejection, and configuration flags.
|
|
211
|
+
|
|
212
|
+
## Interface (Simulation Studio)
|
|
213
|
+
|
|
214
|
+
An interactive Dash + Plotly web interface for running, visualizing, and exporting simulations — open/closed-loop runs, disturbance scenarios, step tests, dataset generation, run comparison, and scenario save/load:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
python3 -m pip install -e ".[ui]"
|
|
218
|
+
python3 -m tep_studio.ui # or: tep-ui ; opens http://127.0.0.1:8050
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
The interface is a thin layer over a Dash-free, importable backend (`from tep_studio.ui import run_scenario, ScenarioConfig, build_dataset`), so the same runs and exports are scriptable. See `docs/ui.md`.
|
|
222
|
+
|
|
223
|
+
## Online Documentation
|
|
224
|
+
|
|
225
|
+
The online documentation source is in `docs/` and is configured by `mkdocs.yml`. It is written as a practical step-by-step guide for new users and is based on the simulator supplement:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
python3 -m pip install -e ".[docs]"
|
|
229
|
+
python3 -m mkdocs serve
|
|
230
|
+
python3 -m mkdocs build --strict
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
(Append `--no-build-isolation` to the install command if your environment blocks
|
|
234
|
+
build isolation, after upgrading the build tools as described under [Build](#build).)
|
|
235
|
+
|
|
236
|
+
The local server defaults to <http://127.0.0.1:8000/>. Start with `docs/getting-started.md`, then run the walkthrough in `docs/first-simulation.md`.
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: TEP Studio
|
|
3
|
+
emoji: 🏭
|
|
4
|
+
colorFrom: blue
|
|
5
|
+
colorTo: indigo
|
|
6
|
+
sdk: docker
|
|
7
|
+
app_port: 7860
|
|
8
|
+
pinned: false
|
|
9
|
+
short_description: Interactive Tennessee Eastman Process simulation studio (Dash + Plotly)
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# TEP Studio
|
|
13
|
+
|
|
14
|
+
This repository contains a schema-driven Python implementation of the modified Tennessee Eastman Process in `temexd_mod`. Simulation code lives in `src/tep_studio/simulation/`; `src/tep_studio/__init__.py` re-exports the public API.
|
|
15
|
+
|
|
16
|
+
The Python package keeps the original `temexd_mod.c` equations as the numerical source of truth by compiling a native CFFI extension, then exposes process-aware Python contracts for:
|
|
17
|
+
|
|
18
|
+
- process-core use through `TennesseeEastmanProcess`
|
|
19
|
+
- Gymnasium RL/control interaction through `GymTEPEnv`
|
|
20
|
+
- causal trajectory datasets through `TrajectoryDataset`
|
|
21
|
+
- deterministic rollout and finite-difference optimization through `OptimizationAdapter`
|
|
22
|
+
- closed-loop decentralized control through `ClosedLoopSimulation` and `RickerMultiLoopController`
|
|
23
|
+
- an interactive Dash + Plotly interface for runs, step tests, and dataset generation (`tep_studio.ui`)
|
|
24
|
+
|
|
25
|
+
## Quickstart
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install tep-studio # add [ui] for the web Simulation Studio
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import tep_studio as tep
|
|
33
|
+
tep.quickstart() # short closed-loop smoke run
|
|
34
|
+
|
|
35
|
+
import gymnasium # a registered RL environment
|
|
36
|
+
env = gymnasium.make("TennesseeEastman-v0", horizon=24.0)
|
|
37
|
+
|
|
38
|
+
from tep_studio import ClosedLoopSimulation # the stabilized closed loop
|
|
39
|
+
result = ClosedLoopSimulation(horizon=24.0).run()
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Or from the terminal: `tep run --horizon 24 --idv idv_01@1.0`, `tep list disturbances`,
|
|
43
|
+
`tep ui`. See the [Cookbook](docs/cookbook.md) for task recipes.
|
|
44
|
+
|
|
45
|
+
## Build
|
|
46
|
+
|
|
47
|
+
Once published to PyPI, `pip install tep-studio` pulls a prebuilt wheel for
|
|
48
|
+
Linux, macOS, and Windows — no C compiler required. The instructions below are for
|
|
49
|
+
building from a source checkout, which compiles the native extension locally.
|
|
50
|
+
|
|
51
|
+
The build requires `setuptools>=68` (declared in `pyproject.toml`). The recommended
|
|
52
|
+
path is an editable install, which uses build isolation to provision the correct
|
|
53
|
+
build dependencies automatically:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
python3 -m pip install -e .
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
If your environment blocks build isolation (for example, an offline machine), first
|
|
60
|
+
ensure the build tools are current, then install without isolation:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
python3 -m pip install -U "setuptools>=68" wheel cffi
|
|
64
|
+
python3 -m pip install -e . --no-build-isolation
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
To build the native extension in place instead of installing, the same
|
|
68
|
+
`setuptools>=68` requirement applies (older setuptools mis-places the compiled
|
|
69
|
+
artifact under the `src/` layout):
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
python3 -m pip install -U "setuptools>=68"
|
|
73
|
+
python3 setup.py build_ext --inplace
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The compiled `_tep_native` extension is platform-specific and is not tracked in
|
|
77
|
+
version control. After moving the repository to a new machine or operating system,
|
|
78
|
+
rebuild it with one of the commands above before importing the package.
|
|
79
|
+
|
|
80
|
+
## Smoke Test
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
PYTHONPATH=src python3 src/tep_studio/simulation/examples/r12_open_loop.py
|
|
84
|
+
PYTHONPATH=src python3 -m pytest -q
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The R12 open-loop example should terminate near 1.07 h with a high reactor pressure shutdown.
|
|
88
|
+
|
|
89
|
+
## Validation
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
PYTHONPATH=src python3 -m tep_studio.simulation.validation run --suite local
|
|
93
|
+
PYTHONPATH=src python3 -m tep_studio.simulation.validation run --suite steady_state
|
|
94
|
+
PYTHONPATH=src python3 -m tep_studio.simulation.validation run --suite mat_states
|
|
95
|
+
PYTHONPATH=src python3 -m tep_studio.simulation.validation run --suite all --solvers RK23 RK45
|
|
96
|
+
PYTHONPATH=src python3 -m tep_studio.simulation.validation figures
|
|
97
|
+
PYTHONPATH=src python3 -m tep_studio.simulation.validation report
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Validation artifacts are written under `src/tep_studio/simulation/validation_outputs/`. The steady-state suite exports the Ricker (1995) Table 2/3 references, compares the simulator base case against the reported Downs and Vogel steady state, and marks optimized modes 1-6 as reference-only unless their electronic 50-state vectors are supplied. The MAT-state suite evaluates the bundled Simulink `CSTATE` vectors for Mode 1, Mode 3, and Skogestad Mode 1 and writes paper-ready comparison tables and figures. Add `--download-external` to cache public reference metadata and files where available.
|
|
101
|
+
|
|
102
|
+
## Closed-Loop Control
|
|
103
|
+
|
|
104
|
+
The base-case plant is open-loop unstable and trips on high reactor pressure within a few hours. The `tep_studio.control` package adds the Ricker (1996) decentralized multiloop PI strategy, which stabilizes the plant for the full horizon:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
PYTHONPATH=src python3 src/tep_studio/control/examples/ricker_mode1_closed_loop.py
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from tep_studio.control import ClosedLoopSimulation
|
|
112
|
+
|
|
113
|
+
result = ClosedLoopSimulation(control_interval=0.0005, horizon=48.0).run()
|
|
114
|
+
assert result.stabilized # ran the horizon without a shutdown
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The controller is separate from the simulator core and consumes only published measurements (no plant-state leakage). It reproduces the loop pairings and gains from Ricker's runnable `MultiLoop_mode1.mdl`, initializes bumplessly from the Mode-1 state, and emits a reproducible experiment record. See `docs/control.md` for the loop structure, overrides, disturbance rejection, and configuration flags.
|
|
118
|
+
|
|
119
|
+
## Interface (Simulation Studio)
|
|
120
|
+
|
|
121
|
+
An interactive Dash + Plotly web interface for running, visualizing, and exporting simulations — open/closed-loop runs, disturbance scenarios, step tests, dataset generation, run comparison, and scenario save/load:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
python3 -m pip install -e ".[ui]"
|
|
125
|
+
python3 -m tep_studio.ui # or: tep-ui ; opens http://127.0.0.1:8050
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The interface is a thin layer over a Dash-free, importable backend (`from tep_studio.ui import run_scenario, ScenarioConfig, build_dataset`), so the same runs and exports are scriptable. See `docs/ui.md`.
|
|
129
|
+
|
|
130
|
+
## Online Documentation
|
|
131
|
+
|
|
132
|
+
The online documentation source is in `docs/` and is configured by `mkdocs.yml`. It is written as a practical step-by-step guide for new users and is based on the simulator supplement:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
python3 -m pip install -e ".[docs]"
|
|
136
|
+
python3 -m mkdocs serve
|
|
137
|
+
python3 -m mkdocs build --strict
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
(Append `--no-build-isolation` to the install command if your environment blocks
|
|
141
|
+
build isolation, after upgrading the build tools as described under [Build](#build).)
|
|
142
|
+
|
|
143
|
+
The local server defaults to <http://127.0.0.1:8000/>. Start with `docs/getting-started.md`, then run the walkthrough in `docs/first-simulation.md`.
|