Skip to content

CesarGarech/Biocontrol_modeling_project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Modeling and control applied to bioprocess

An interactive Streamlit application for teaching modeling, simulation, analysis, and control of bioprocesses.

πŸ“– Overview

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.

πŸš€ Features

  • 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) in Utils/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.

πŸ“¦ Installation

Option 1: Quick Start (Windows)

Just run the provided batch script:

run_dashboard.bat

This will automatically create a virtual environment, install dependencies, and launch the dashboard.

Option 2: Manual Installation

Ensure you have Python 3.8 or higher installed. Then:

  1. Clone the repository:
git clone https://github.com/CesarGarech/Biocontrol_modeling_project.git
cd Biocontrol_modeling_project
  1. 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
  1. 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
  1. Run the application:
streamlit run main.py

πŸ“‚ Repository Structure

Biocontrol_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

✏️ Authors & Contributors

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.

πŸ“š Theoretical Background

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.

Bioprocess Engineering and Modeling

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 = Ξ±Β·ΞΌ + Ξ²)

Classical Process Control

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

Advanced Process Control

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

State Estimation

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

Numerical Methods and Optimization

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

Statistical Methods

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

Software and Tools

  • 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.

πŸ”¬ Publications & Citations

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}
}

πŸ›‘ License

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).

πŸ“ž Contact

For any inquiries, please contact CΓ©sar Augusto GarcΓ­a Echeverry at [email protected] or open an issue in this repository.

⭐ Acknowledgments

We acknowledge the support of COPPE/UFRJ, [Funding Agency, if any], and all contributors.

About

Repository referring to the theoretical material of CABBIO BR03. (under construction)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 7