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 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.
uv sync
See the examples directory
- see examples/batch_generation.py to generate batch and Raman data with self-designed recipes
- see examples/reinforcement_learning_boilerplate.py to simulate penicillin yield process with reinforcement learning
uv run pytest
The end-to-end tests simulate full 230 h batches and take about a minute.
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.stepand 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_mhours withOff_line_delaysteps of delay) are recorded again; the float remainder test never fired. - Integration grid. The 40 sub-steps per control interval are generated
with
linspace;arangeovershot by one sub-step at some steps. - Episode reset zeroes the yield accumulator, and
PenSimEnvGym.resetacceptsseed=in gymnasium style. - Integrator failure (volume or H⁺ driven to zero by extreme actions) is
reported by
PenSimEnvGym.stepas a terminated episode withinfo["integrator_failure"]instead of an exception.
