An interactive Streamlit application for teaching modeling, simulation, analysis, and control of bioprocesses.
This repository contains the source code for Biocontrol_modeling_project, developed by CΓ©sar Augusto GarcΓa Echeverry at the Laboratory of Software Development for Process Control and Optimization (LADES) - COPPE/UFRJ.
The purpose of this project is to assist in teaching classical and advanced modeling and control techniques within the fields of bioprocessing and biotechnology. It provides interactive tools built using robust programming methods, serving as a resource for education, research, development, and collaboration.
-
Interactive Bioprocess Simulation: Simulate various bioreactor operation modes (Batch, Fed-Batch, Continuous) using ODE models solved with
scipy. - Specific Fermentation Modeling: Includes a dedicated model for alcoholic fermentation simulating batch and fed-batch phases with complex yeast kinetics.
-
Kinetic Model Library: Centralized definitions for various specific growth rate (
$\mu$ ) models (Monod, Sigmoidal, Substrate/Product/Oxygen Inhibition) inUtils/kinetics.py, including CasADi-compatible versions. -
Parameter Estimation: Fit kinetic model parameters to experimental data (loaded from Excel files) using optimization algorithms (
scipy.optimize) and perform statistical analysis (RΒ², RMSE, confidence intervals). - Sensitivity Analysis: Evaluate the impact of kinetic parameter variations on simulation outcomes.
- State Estimation: Implement an Extended Kalman Filter (EKF) using CasADi to estimate unmeasurable states (Biomass, Substrate, Product) and parameters from noisy simulated measurements.
- Regulatory Process Control: Simulate basic PID control loops for Temperature, pH (split-range), Dissolved Oxygen (via agitation), and On/Off substrate feeding.
- Advanced Process Control: Implement Real-Time Optimization (RTO) and Nonlinear Model Predictive Control (NMPC) using CasADi and IPOPT to find optimal operating profiles (e.g., feed rate) subject to constraints.
-
Interactive User Interface: Built with Streamlit (
main.py) for easy navigation and visualization using Matplotlib.
Just run the provided batch script:
run_dashboard.batThis will automatically create a virtual environment, install dependencies, and launch the dashboard.
Ensure you have Python 3.8 or higher installed. Then:
- Clone the repository:
git clone https://github.com/CesarGarech/Biocontrol_modeling_project.git
cd Biocontrol_modeling_project- Create and activate a virtual environment (recommended):
# Create virtual environment
python -m venv venv
# Activate on Linux/Mac
source venv/bin/activate
# Activate on Windows
venv\Scripts\activate- Install the package and dependencies:
# Option A: Install in development mode
pip install -e .
# Option B: Install just the requirements
pip install -r requirements.txt- Run the application:
streamlit run main.pyBiocontrol_modeling_project/
βββ Body/ # Core modules: modeling, analysis, estimation, control
β βββ __init__.py
β βββ modeling/ # Bioreactor simulation modes (batch, fed-batch, etc.)
β β βββ __init__.py
β β βββ lote.py # Batch reactor
β β βββ lote_alimentado.py # Fed-batch reactor
β β βββ continuo.py # Continuous reactor (chemostat)
β β βββ ferm_alcohol.py # Alcoholic fermentation
β βββ analysis.py # Sensitivity analysis code
β βββ parameter_estimation/ # Parameter estimation modules
β β βββ __init__.py
β β βββ ajuste_parametros_lote.py # Batch parameter fitting
β β βββ ajuste_parametros_lote_alim.py # Fed-batch parameter fitting
β β βββ ajuste_parametros_ferm.py # Fermentation parameter fitting
β βββ estimation/ # State estimation (EKF, ANN)
β β βββ __init__.py
β β βββ ekf.py # Extended Kalman Filter
β β βββ ann.py # Artificial Neural Network
β βββ control/ # Process control strategies
β β βββ __init__.py
β β βββ regulatorio/ # Regulatory (PID) control
β β β βββ __init__.py
β β β βββ reg_temp.py, reg_ph.py, reg_oxigeno.py, etc.
β β βββ avanzado/ # Advanced control (RTO, NMPC)
β β βββ __init__.py
β β βββ rto.py, rto_ferm.py, nmpc.py
β βββ home.py # Home page content
βββ Utils/ # Utility functions
β βββ __init__.py
β βββ kinetics.py # Kinetic model definitions (Monod, etc.)
βββ Data/ # Example experimental datasets (.xlsx)
βββ Examples/ # Standalone examples (EKF, RTO, NMPC CasADi scripts)
βββ test_data/ # Test data files
βββ Images/ # Images for documentation and UI
βββ Output/ # Output files from simulations
βββ setup.py # Package setup configuration
βββ main.py # Main Streamlit application entry point
βββ README.md # Project documentation (this file)
βββ requirements.txt # Python dependencies list
βββ run_dashboard.bat # Windows batch script to run the dashboard
This project was primarily developed by CΓ©sar Augusto GarcΓa Echeverry at the Laboratory of Software Development for Process Control and Optimization (LADES) - COPPE/UFRJ.
-CΓ©sar Augusto GarcΓa Echeverry - Lead Developer - [[email protected]]
-Andres Mateo Franco Reyes - Developer - [[email protected]]
-Juan Pablo Velez Orjuela - Developer - [[email protected]]
-Carolina del Mar GΓ‘mez Herazo - Developer - [[email protected]]
We welcome contributions! Please refer to the contribution guidelines (if available) or open an issue/pull request.
This project is built upon well-established theoretical foundations in bioprocess engineering, process control, optimization, and numerical methods. The following sections provide key references for understanding the underlying theory.
Kinetic Models and Microbial Growth:
-
Shuler, M. L., & Kargi, F. (2002). Bioprocess Engineering: Basic Concepts (2nd ed.). Prentice Hall.
- Comprehensive coverage of microbial kinetics including Monod, Haldane, and substrate/product inhibition models
- Mass balance equations for batch, fed-batch, and continuous bioreactors
-
Bailey, J. E., & Ollis, D. F. (1986). Biochemical Engineering Fundamentals (2nd ed.). McGraw-Hill.
- Foundational text on bioprocess modeling and stoichiometry
- Detailed treatment of oxygen transfer (kLa) and metabolic pathways
-
Luedeking, R., & Piret, E. L. (1959). "A kinetic study of the lactic acid fermentation. Batch process at controlled pH." Journal of Biochemical and Microbiological Technology and Engineering, 1(4), 393-412.
- Classic paper establishing the Luedeking-Piret model for product formation (qP = Ξ±Β·ΞΌ + Ξ²)
PID Control and Regulatory Strategies:
-
Smith, C. A., & Corripio, A. B. (2005). Principles and Practice of Automatic Process Control (3rd ed.). John Wiley & Sons.
- Standard reference for PID controller design and tuning
- Cascade control, split-range control, and feedforward strategies
- Chapters on controller tuning methods (Ziegler-Nichols, Cohen-Coon, etc.)
-
Stephanopoulos, G. (1984). Chemical Process Control: An Introduction to Theory and Practice. Prentice Hall.
- Comprehensive treatment of feedback and feedforward control
- Process dynamics, transfer functions, and frequency response
-
Seborg, D. E., Edgar, T. F., Mellichamp, D. A., & Doyle III, F. J. (2016). Process Dynamics and Control (4th ed.). John Wiley & Sons.
- Modern perspective on process control with extensive examples
- Digital control implementation and discrete-time systems
Model Predictive Control (MPC/NMPC):
-
Camacho, E. F., & Bordons, C. (2007). Model Predictive Control (2nd ed.). Springer-Verlag.
- Comprehensive coverage of linear and nonlinear MPC formulations
- Constraint handling and optimization problem formulation
-
Rawlings, J. B., Mayne, D. Q., & Diehl, M. (2017). Model Predictive Control: Theory, Computation, and Design (2nd ed.). Nob Hill Publishing.
- Advanced treatment of MPC theory including stability and robustness
- Nonlinear MPC and moving horizon estimation
Real-Time Optimization (RTO):
-
Biegler, L. T. (2010). Nonlinear Programming: Concepts, Algorithms, and Applications to Chemical Processes. SIAM.
- Mathematical foundations for RTO and dynamic optimization
- IPOPT and other NLP solvers
-
Marlin, T. E. (2000). Process Control: Designing Processes and Control Systems for Dynamic Performance (2nd ed.). McGraw-Hill.
- Integration of process design and control
- Real-time optimization in the context of process operations
Extended Kalman Filter (EKF) and Observers:
-
Jazwinski, A. H. (1970). Stochastic Processes and Filtering Theory. Academic Press.
- Theoretical foundation of Kalman filtering for nonlinear systems
-
Simon, D. (2006). Optimal State Estimation: Kalman, Hβ, and Nonlinear Approaches. John Wiley & Sons.
- Practical treatment of EKF implementation
- Application to nonlinear bioprocess systems
-
Bastin, G., & Dochain, D. (1990). On-line Estimation and Adaptive Control of Bioreactors. Elsevier.
- Specialized reference for bioprocess state estimation
- Asymptotic observers and adaptive control
Ordinary Differential Equations (ODEs):
- Press, W. H., Teukolsky, S. A., Vetterling, W. T., & Flannery, B. P. (2007). Numerical Recipes: The Art of Scientific Computing (3rd ed.). Cambridge University Press.
- Implementation of Runge-Kutta and other ODE solvers
- Used by scipy.integrate.solve_ivp
Optimization Algorithms:
-
Nocedal, J., & Wright, S. J. (2006). Numerical Optimization (2nd ed.). Springer.
- Comprehensive coverage of optimization theory
- Levenberg-Marquardt, Sequential Quadratic Programming (SQP), and interior-point methods
-
Andersson, J. A. E., Gillis, J., Horn, G., Rawlings, J. B., & Diehl, M. (2019). "CasADi: a software framework for nonlinear optimization and optimal control." Mathematical Programming Computation, 11(1), 1-36.
- CasADi framework used for NMPC and RTO in this project
Parameter Estimation and Confidence Intervals:
-
Bard, Y. (1974). Nonlinear Parameter Estimation. Academic Press.
- Theory and methods for fitting kinetic parameters to experimental data
-
Beck, J. V., & Arnold, K. J. (1977). Parameter Estimation in Engineering and Science. John Wiley & Sons.
- Statistical analysis of parameter estimates
- Confidence intervals and sensitivity coefficients
Design of Experiments:
- Box, G. E. P., Hunter, W. G., & Hunter, J. S. (2005). Statistics for Experimenters: Design, Innovation, and Discovery (2nd ed.). John Wiley & Sons.
- Experimental design for bioprocess optimization
- SciPy: Virtanen, P., et al. (2020). "SciPy 1.0: fundamental algorithms for scientific computing in Python." Nature Methods, 17(3), 261-272.
- NumPy: Harris, C. R., et al. (2020). "Array programming with NumPy." Nature, 585(7825), 357-362.
- Streamlit: Used for interactive dashboard development
- Matplotlib: Hunter, J. D. (2007). "Matplotlib: A 2D graphics environment." Computing in Science & Engineering, 9(3), 90-95.
If you use this work in your research, please cite the following:
GitHub Repository: https://github.com/CesarGarech/Biocontrol_modeling_project
@software{Garcia2024Biocontrol,
author = {GarcΓa Echeverry, CΓ©sar Augusto and Franco Reyes, AndrΓ©s Mateo and VΓ©lez Orjuela, Juan Pablo and GΓ‘mez Herazo, Carolina del Mar},
title = {Biocontrol Modeling Project: Interactive Tools for Bioprocess Control Education},
year = {2024},
url = {https://github.com/CesarGarech/Biocontrol_modeling_project},
institution = {LADES - COPPE/UFRJ}
}
This work is licensed under the Creative Commons Attribution 4.0 International (CC BY 4.0) License (or specify your chosen license). You are free to:
Use, modify, and distribute this code for any purpose.
Cite the appropriate reference when using this code (see References section).
[Author(s) Name].
"[Title of Paper or Project]",
[Journal/Conference Name], vol. [XX], no. [X], [Year].
[DOI: [DOI or URL]]([Link to Paper])
See the full license details in the https://www.google.com/search?q=LICENSE file (ensure you have this file).
For any inquiries, please contact CΓ©sar Augusto GarcΓa Echeverry at [email protected] or open an issue in this repository.
We acknowledge the support of COPPE/UFRJ, [Funding Agency, if any], and all contributors.