Skip to content
iasxPublic
forked from smpl-env/PenSimPy

About

The Python implementation of IndPenSim

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

159 Commits

Folders and files

Repository files navigation

alt text

Development Status: As of 08/2020 PenSimPy is under active maintenance (expect bug fixes and updates). Please follow, star, and fork to get the latest functions.

PenSimPy

PenSimPy is a Python version of IndPenSim, which simulates the industrial-scale Penicillium chrysogenum fermentation.

PenSimPy aims for recording those key features such as pH, temperature, vessel volume, vessel weight, penicillin concentration, dissolved oxygen concentration, sugar feed rate, soil bean feed rate, aeration rate, back pressure, water, acid, phenylacetic acid flow-rate, Oxygen in percent in off-gas, and the Raman spectroscopy data throughout the whole process. A conventionally used Sequential Batch Control strategy with PID control is presented with example codes and all the recipe's feed can be manually updated.

Furthermore, we incorporate Reinforcement Learning to improve the penicillin gain and present them as example codes. A web application based on PenSimPy can be found here.

Installation

uv sync

Examples

See the examples directory

Tests

uv run pytest

The end-to-end tests simulate full 230 h batches and take about a minute.

Changes relative to upstream smpl-env/PenSimPy

This fork targets Python 3.12 / numpy 2 with scipy's odeint (the C++ fastodeint dependency is dropped) and fixes the following defects, each covered by a test in tests/:

  • Recipe setpoint semantics. Each setpoint now holds until its listed time, as in IndPenSim and the bundled example batches (150 L/h sugar pulse on 20–24 h, 2 h broth discharges at 100, 130, 150, 170, 190, 210 h). The old code held each value from its time, which discharged for 28 h windows and drained the vessel.
  • Recipe time units. PenSimEnvGym.step and the RL boilerplate queried the recipe in minutes although profiles are in hours; after 4 h every run sat on the end-of-batch setpoints.
  • Process disturbances are drawn from one sequential random stream; the eight series used to be scaled copies of the same white-noise sequence.
  • Off-line assays (P, X, PAA, NH3, viscosity every Off_line_m hours with Off_line_delay steps of delay) are recorded again; the float remainder test never fired.
  • Integration grid. The 40 sub-steps per control interval are generated with linspace; arange overshot by one sub-step at some steps.
  • Episode reset zeroes the yield accumulator, and PenSimEnvGym.reset accepts seed= in gymnasium style.
  • Integrator failure (volume or H⁺ driven to zero by extreme actions) is reported by PenSimEnvGym.step as a terminated episode with info["integrator_failure"] instead of an exception.

About

The Python implementation of IndPenSim

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages