Skip to main content

Schema-driven Python simulator for the modified Tennessee Eastman Process.

Project description

TEP Studio

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.

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:

  • process-core use through TennesseeEastmanProcess
  • Gymnasium RL/control interaction through GymTEPEnv
  • causal trajectory datasets through TrajectoryDataset
  • deterministic rollout and finite-difference optimization through OptimizationAdapter
  • closed-loop decentralized control through ClosedLoopSimulation and RickerMultiLoopController
  • an interactive Dash + Plotly interface for runs, step tests, and dataset generation (tep_studio.ui)

Quickstart

pip install tep-studio            # add [ui] for the web Simulation Studio
import tep_studio as tep
tep.quickstart()                                  # short closed-loop smoke run

import gymnasium                                   # a registered RL environment
env = gymnasium.make("TennesseeEastman-v0", horizon=24.0)

from tep_studio import ClosedLoopSimulation     # the stabilized closed loop
result = ClosedLoopSimulation(horizon=24.0).run()

Or from the terminal: tep run --horizon 24 --idv idv_01@1.0, tep list disturbances, tep ui. See the Cookbook for task recipes.

Build

Once published to PyPI, pip install tep-studio pulls a prebuilt wheel for Linux, macOS, and Windows — no C compiler required. The instructions below are for building from a source checkout, which compiles the native extension locally.

The build requires setuptools>=68 (declared in pyproject.toml). The recommended path is an editable install, which uses build isolation to provision the correct build dependencies automatically:

python3 -m pip install -e .

If your environment blocks build isolation (for example, an offline machine), first ensure the build tools are current, then install without isolation:

python3 -m pip install -U "setuptools>=68" wheel cffi
python3 -m pip install -e . --no-build-isolation

To build the native extension in place instead of installing, the same setuptools>=68 requirement applies (older setuptools mis-places the compiled artifact under the src/ layout):

python3 -m pip install -U "setuptools>=68"
python3 setup.py build_ext --inplace

The compiled _tep_native extension is platform-specific and is not tracked in version control. After moving the repository to a new machine or operating system, rebuild it with one of the commands above before importing the package.

Smoke Test

PYTHONPATH=src python3 src/tep_studio/simulation/examples/r12_open_loop.py
PYTHONPATH=src python3 -m pytest -q

The R12 open-loop example should terminate near 1.07 h with a high reactor pressure shutdown.

Validation

PYTHONPATH=src python3 -m tep_studio.simulation.validation run --suite local
PYTHONPATH=src python3 -m tep_studio.simulation.validation run --suite steady_state
PYTHONPATH=src python3 -m tep_studio.simulation.validation run --suite mat_states
PYTHONPATH=src python3 -m tep_studio.simulation.validation run --suite all --solvers RK23 RK45
PYTHONPATH=src python3 -m tep_studio.simulation.validation figures
PYTHONPATH=src python3 -m tep_studio.simulation.validation report

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.

Closed-Loop Control

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:

PYTHONPATH=src python3 src/tep_studio/control/examples/ricker_mode1_closed_loop.py
from tep_studio.control import ClosedLoopSimulation

result = ClosedLoopSimulation(control_interval=0.0005, horizon=48.0).run()
assert result.stabilized  # ran the horizon without a shutdown

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.

Interface (Simulation Studio)

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:

python3 -m pip install -e ".[ui]"
python3 -m tep_studio.ui          # or: tep-ui ; opens http://127.0.0.1:8050

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.

Online Documentation

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:

python3 -m pip install -e ".[docs]"
python3 -m mkdocs serve
python3 -m mkdocs build --strict

(Append --no-build-isolation to the install command if your environment blocks build isolation, after upgrading the build tools as described under Build.)

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tep_studio-0.1.1.tar.gz (151.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tep_studio-0.1.1-cp313-cp313-win_amd64.whl (164.4 kB view details)

Uploaded CPython 3.13Windows x86-64

tep_studio-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (208.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

tep_studio-0.1.1-cp313-cp313-macosx_11_0_arm64.whl (162.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

tep_studio-0.1.1-cp312-cp312-win_amd64.whl (164.4 kB view details)

Uploaded CPython 3.12Windows x86-64

tep_studio-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (208.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

tep_studio-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (162.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

tep_studio-0.1.1-cp311-cp311-win_amd64.whl (164.3 kB view details)

Uploaded CPython 3.11Windows x86-64

tep_studio-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (208.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

tep_studio-0.1.1-cp311-cp311-macosx_11_0_arm64.whl (162.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

tep_studio-0.1.1-cp310-cp310-win_amd64.whl (164.3 kB view details)

Uploaded CPython 3.10Windows x86-64

tep_studio-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (208.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

tep_studio-0.1.1-cp310-cp310-macosx_11_0_arm64.whl (162.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file tep_studio-0.1.1.tar.gz.

File metadata

  • Download URL: tep_studio-0.1.1.tar.gz
  • Upload date:
  • Size: 151.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tep_studio-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ef103c18c3265b3e0cbc13f5a55798b7dca30496a2626f2e2b8c5d0c05f324a4
MD5 abf681733fc817c470a0f10f5c42ae58
BLAKE2b-256 8baf4ec7b537578a701a016c5bf3b20e67321b45a6cb67164beb04c16f01207b

See more details on using hashes here.

Provenance

The following attestation bundles were made for tep_studio-0.1.1.tar.gz:

Publisher: wheels.yml on khalidlabs/tep-studio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tep_studio-0.1.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: tep_studio-0.1.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 164.4 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tep_studio-0.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 03a350744f0cd6064669f6f77ae5709d35c8fad573c5eee7ba0eae96081ddbb5
MD5 b617bcc8787eea97a739030675efbf61
BLAKE2b-256 16d5884f3798241fa8ba4195601ec575ecd8566bad1f9949b9b28adb2f513d70

See more details on using hashes here.

Provenance

The following attestation bundles were made for tep_studio-0.1.1-cp313-cp313-win_amd64.whl:

Publisher: wheels.yml on khalidlabs/tep-studio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tep_studio-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tep_studio-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c31f5d62f7aa7144690b978e11e3d814ac278a8cae949b9e7ab022119faae95f
MD5 e4dfc9ed04ba2ee759ac00a66c36d866
BLAKE2b-256 b88d28da4bf61c6eedef5c0619432fc1ff048d9bc27e4f053e6c509a92f944cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for tep_studio-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on khalidlabs/tep-studio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tep_studio-0.1.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tep_studio-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c1f6ce08f9baed156a1bb76a17eaffee0b80fb02c55ee29fc717719912e105bd
MD5 61c5747e4af6cb75f4d37859101f689a
BLAKE2b-256 2e8c7d7b5325c7963e2f98d0d055bf0e157adefc30213c2303b0c951a81ea08d

See more details on using hashes here.

Provenance

The following attestation bundles were made for tep_studio-0.1.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: wheels.yml on khalidlabs/tep-studio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tep_studio-0.1.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: tep_studio-0.1.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 164.4 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tep_studio-0.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 50c01d67198403492babcb6c1dfd5549f17c0450f2c2d70f78c4d22b78613e5d
MD5 5308ad2945fb368da7393a20a8d8f681
BLAKE2b-256 a134481595e1457a2832567493473a2c29738d077647caa65deaa36df815b94f

See more details on using hashes here.

Provenance

The following attestation bundles were made for tep_studio-0.1.1-cp312-cp312-win_amd64.whl:

Publisher: wheels.yml on khalidlabs/tep-studio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tep_studio-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tep_studio-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 20c8751a413f4c376204a0022e79caa9e5cc757e68ce5ce2f1d4c40ab7769840
MD5 46ffa8f33b4ac891c75a2ba508458a93
BLAKE2b-256 35c4d39050c2538a8db3c1348e49cbb7b81fde37b179a72a776eaf688931cadb

See more details on using hashes here.

Provenance

The following attestation bundles were made for tep_studio-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on khalidlabs/tep-studio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tep_studio-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tep_studio-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4603d73d51d21080ae906e2dcaa06f374fd56976cca9800ff7335e237cf180aa
MD5 77f8c29976348ca7bd12f4ad21d1d26e
BLAKE2b-256 fed16c5ec6f49e0d2ea3982c7d0e4c329eb77a501173bd5547df0e773e192936

See more details on using hashes here.

Provenance

The following attestation bundles were made for tep_studio-0.1.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: wheels.yml on khalidlabs/tep-studio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tep_studio-0.1.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: tep_studio-0.1.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 164.3 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tep_studio-0.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3db5f43f7222a6a4502c4de645fb34644b6ee44a59f7bd7232cdee07b28cb246
MD5 a26f08e45724e21981ea5462538e18fe
BLAKE2b-256 4cfefa061064f04eeb2dc9a305a58263f1820cfbaabe4814aec65014b5d2e20d

See more details on using hashes here.

Provenance

The following attestation bundles were made for tep_studio-0.1.1-cp311-cp311-win_amd64.whl:

Publisher: wheels.yml on khalidlabs/tep-studio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tep_studio-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tep_studio-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 12e877b4a9a615749fea15893acf6fbebee2b884802169209c5aca662ef2d6ca
MD5 d734951bf26dc97fa2ea8e5baa7e90b6
BLAKE2b-256 ab9207de20f8051a93cc45334136f2695650225646bd477ef713c19dcdfd088b

See more details on using hashes here.

Provenance

The following attestation bundles were made for tep_studio-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on khalidlabs/tep-studio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tep_studio-0.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tep_studio-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c6d7e1db6e81e4bc9c4a62b3939a928c44d9792e4f08fa8b76674abba1da5564
MD5 6810378b0a2b6953827c0460a5258441
BLAKE2b-256 6db770b778d5cdf090295c9237447ee0db7cb8344cdef29895ad246473a73797

See more details on using hashes here.

Provenance

The following attestation bundles were made for tep_studio-0.1.1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: wheels.yml on khalidlabs/tep-studio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tep_studio-0.1.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: tep_studio-0.1.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 164.3 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tep_studio-0.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1526ef792d58291a74d1915ea2d72a4d26e1e539f9e67cbf9ffd82b15a42c2cc
MD5 e159375e0135f9cd2e04196b62cb567d
BLAKE2b-256 419cb93498562547d9ff1487e83ac7d9882ad54150203d0227a6b84ba00ce09e

See more details on using hashes here.

Provenance

The following attestation bundles were made for tep_studio-0.1.1-cp310-cp310-win_amd64.whl:

Publisher: wheels.yml on khalidlabs/tep-studio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tep_studio-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tep_studio-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2978a3a271cff248ba9ab969add76c2f24365189848e283ffc8942b130d6afca
MD5 a62fafb71e4480b0301e765fb6572896
BLAKE2b-256 2a51cdff05be6f369e15bd4cdca8ca8843ec0fa4467b290416e68f60b4198d8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for tep_studio-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on khalidlabs/tep-studio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tep_studio-0.1.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tep_studio-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 69bcc2c8cf7b049112b29ecd8d993de3645a73d5ab646867206b5d8523b9a460
MD5 c25006bb3312075a0311b98380109f16
BLAKE2b-256 e379a885d84afbd9e977c7ab7c07a34da413809b795c59dd6a23f07f956b5266

See more details on using hashes here.

Provenance

The following attestation bundles were made for tep_studio-0.1.1-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: wheels.yml on khalidlabs/tep-studio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page