Skip to content

yajeddig/distillation-column-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงช Distillation Column Simulator

Fortran Python Streamlit License

Advanced multi-stage continuous distillation column simulator with NRTL thermodynamic model and optimized numerical solvers.

๐ŸŽ“ Academic Origin: Originally developed as a student project at ENSGTI (ร‰cole Nationale Supรฉrieure en Gรฉnie des Technologies Industrielles) in 2018. Refactored and modernized for production use with web interface and comprehensive documentation.


โœจ Features

๐Ÿ”ฌ Rigorous Scientific Models

  • MESH Equations: Material balance, Equilibrium, Summation, Heat balance
  • NRTL Model: Non-Random Two-Liquid theory for non-ideal mixtures
  • Vapor-Liquid Equilibrium: Activity coefficient calculations
  • Enthalpy Calculations: Rigorous heat balances

๐Ÿงฎ Advanced Numerical Methods

  • Newton-Raphson solver for non-linear systems
  • Block Tridiagonal Matrix optimization (MRSL21 algorithm)
  • Full Matrix solver (MRSL01) for comparison
  • Analytical Jacobian with numerical perturbations

๐Ÿ’ป Modern Architecture

  • High-Performance Backend: Fortran 90 for computational efficiency
  • Python Wrapper: Easy integration with modern workflows
  • Interactive Web UI: Streamlit-based interface with real-time visualization
  • YAML Configuration: Human-readable simulation setup

๐Ÿš€ Quick Start

Prerequisites

# System requirements
- gfortran (GCC Fortran compiler)
- Python 3.8+
- uv (Python package manager)
- Make

# Check installations
gfortran --version
python3 --version
uv --version

๐Ÿ“ฆ Using uv: This project uses uv for fast, reliable Python dependency management. Install with: curl -LsSf https://astral.sh/uv/install.sh | sh (see docs/UV_GUIDE.md for details)

Installation

# Clone repository
git clone https://github.com/yourusername/distillation-column-simulator.git
cd distillation-column-simulator

# Install Python dependencies with uv (recommended)
uv sync

# Or use pip (alternative)
pip install -r frontend/requirements.txt

# Compile Fortran backend
cd backend
make
cd ..

Run Web Interface

# With uv (recommended)
uv run streamlit run frontend/app.py

# Or activate venv first
source .venv/bin/activate  # Linux/macOS
streamlit run frontend/app.py

The application will open in your browser at http://localhost:8501

Run from Command Line

# Compile backend
cd backend && make

# Edit configuration
nano ../config/simulation_config.yaml

# Run simulation
./distillation

# Results saved to RESULTS.csv

๐Ÿ“Š Example: Acetone-Benzene-Chloroform Separation

column:
  n_stages: 30
  pressure_atm: 1.0

feeds:
  - stage: 14
    flow_rate: 1.0
    composition:
      acetone: 0.6
      benzene: 0.3
      chloroform: 0.1

thermal:
  reboiler_duty: 21000.0    # cal/s
  condenser_duty: 15000.0   # cal/s

System Features:

  • Ternary mixture with azeotrope (Acetone-Chloroform at 66/34%)
  • Non-ideal behavior (NRTL model essential)
  • 30 theoretical stages
  • Typical convergence: ~1700 iterations, 50 seconds

๐Ÿ“ Project Structure

distillation-simulator/
โ”œโ”€โ”€ backend/                  # Fortran computational engine
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ modules/         # Global variable modules
โ”‚   โ”‚   โ”œโ”€โ”€ thermodynamics/  # NRTL, equilibrium, enthalpies
โ”‚   โ”‚   โ”œโ”€โ”€ solvers/         # MRSL01, MRSL21 linear solvers
โ”‚   โ”‚   โ””โ”€โ”€ utils/           # Utilities (norms, residuals)
โ”‚   โ””โ”€โ”€ Makefile             # Build system
โ”‚
โ”œโ”€โ”€ python/                   # Python wrapper package
โ”‚   โ””โ”€โ”€ distillation_wrapper/
โ”‚       โ”œโ”€โ”€ fortran_interface.py
โ”‚       โ”œโ”€โ”€ config_manager.py
โ”‚       โ””โ”€โ”€ data_processor.py
โ”‚
โ”œโ”€โ”€ frontend/                 # Streamlit web application
โ”‚   โ”œโ”€โ”€ app.py               # Main application
โ”‚   โ””โ”€โ”€ components/          # UI components
โ”‚
โ”œโ”€โ”€ config/                   # Configuration files
โ”‚   โ”œโ”€โ”€ simulation_config.yaml
โ”‚   โ”œโ”€โ”€ components.yaml
โ”‚   โ””โ”€โ”€ examples/
โ”‚
โ”œโ”€โ”€ docs/                     # Documentation
โ”‚   โ”œโ”€โ”€ scientific/          # Theory and equations
โ”‚   โ”œโ”€โ”€ technical/           # API and usage
โ”‚   โ””โ”€โ”€ original/            # Original 2018 project docs
โ”‚
โ””โ”€โ”€ results/                  # Simulation outputs

๐Ÿ“š Documentation

Scientific Background

Technical Documentation

Original Project (2018)


๐Ÿ”ง Development

Compile Backend

cd backend
make clean && make

Run Tests

# Python tests
pytest tests/python/

# Fortran validation
cd tests/fortran && ./run_validation.sh

Code Style

  • Fortran: Fortran 90 standard, detailed comments
  • Python: PEP 8, type hints, docstrings
  • Git: Conventional commits

๐Ÿ“ˆ Performance

Solver Method Avg. Time Iterations Memory
MRSL21 Block Tridiagonal ~20s ~1700 Low
MRSL01 Full Matrix ~26s ~1700 Higher

Benchmark: 30 stages, acetone-benzene-chloroform, convergence 10โปโถ


๐ŸŽ“ Academic Background

Original Project (2018)

  • Institution: ENSGTI Pau, France
  • Course: Modรฉlisation des opรฉrations unitaires II
  • Instructor: Pr. Frรฉdรฉric MARIAS
  • Student: Younes AJEDDIG

Modernization (2025)

  • Refactored for production use
  • Added web interface
  • Comprehensive documentation
  • CI/CD integration

๐Ÿค Contributing

Contributions welcome! Please see CONTRIBUTING.md for guidelines.

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

๐Ÿ“ License

This project is licensed under the MIT License - see LICENSE file for details.


๐Ÿ™ Acknowledgments

  • ENSGTI for the original academic framework
  • Frรฉdรฉric MARIAS for scientific guidance (2018)
  • Open-source community for tools and libraries

๐Ÿ“ง Contact

Younes AJEDDIG



Made with โค๏ธ for Process & Chemical Engineering

About

Continuous distillation column simulator using MESH equations, NRTL thermodynamics, and Newton-Raphson solver. Fortran backend with Python wrapper and Streamlit web interface.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors