🛢️ Research-Grade Petroleum Refinery Optimization Platform
From Excel to Exascale: A complete toolkit for refinery blending, planning, and optimization.
RefineryOpt is an open-source Python framework for petroleum refinery optimization combining:
- Scientifically Accurate Blending — Non-linear correlations per ASTM/API standards
- Process Unit Modeling — CDU, FCC, Reformer, Hydrotreater yield models
- Environmental Compliance — EPA Tier 3, IMO 2020, RFS2 constraints
- Carbon Footprint Tracking — Scope 1, 2, 3 emissions per GHG Protocol
- Differentiable Simulation — GPU-accelerated optimization via JAX
# Clone and install
git clone https://github.com/thookham/RefineryOpt.git
cd RefineryOpt
pip install -e .
# Run simple blending optimization
python refinery_opt.py examples/gasoline.json --solver scipyOutput:
Status: optimal
Cost: $831,332.14
| Module | Description |
|---|---|
| Blending | RVP, viscosity, flash point, octane correlations |
| Process Units | CDU, FCC, Reformer, Hydrotreater models |
| Environmental | EPA Tier 3, IMO 2020, RFS2 constraints |
| Economics | Crack spreads, gross margin optimization |
| Feature | Description |
|---|---|
| Octane Modeling | Interaction matrix, Ethyl method, blending values |
| Carbon Tracking | Scope 1/2/3 emissions per GHG Protocol |
| JAX Integration | Differentiable blending with GPU acceleration |
| Feature | Description |
|---|---|
| Streamlit Dashboard | Web-based GUI for non-programmers |
| Chance-Constrained Programming | Probabilistic constraints |
| ML Surrogates | PyTorch neural network approximations |
| Decomposition | Benders, Lagrangean Relaxation |
pip install -e .pip install jax==0.5.0 jaxlib==0.5.0 intel-extension-for-openxla==0.7.0| Package | Purpose |
|---|---|
pyomo |
Optimization modeling |
pydantic |
Data validation |
numpy, scipy, pandas |
Numerical computing |
jax |
Differentiable programming (optional) |
RefineryOpt/
├── refinery_opt.py # CLI entry point
├── src/
│ ├── blending/ # RVP, viscosity, octane
│ ├── constraints/ # EPA, IMO, carbon
│ ├── crude/ # Assay handling
│ ├── units/ # CDU, FCC, Reformer
│ ├── economics/ # Margins, crack spreads
│ ├── uncertainty/ # Monte Carlo, CVaR, CCP
│ ├── models/ # Pyomo LP/NLP/MILP
│ ├── solvers/ # CBC, GLPK, Gurobi, SciPy
│ └── ml/ # JAX, PyTorch surrogates
├── dashboard/ # Streamlit GUI
├── examples/ # Sample configs
├── benchmarks/ # Li, Haverly, Pinto
└── tests/ # Unit tests
| Property | Model |
|---|---|
| RVP | (Σ xᵢ·RVPᵢ^1.25)^0.8 (Chevron Index) |
| Viscosity | Refutas Index |
| Flash Point | Inverse blending |
| Octane | Ethyl/Interaction matrix |
| Scope | Source |
|---|---|
| 1 | Direct combustion (process units) |
| 2 | Purchased electricity |
| 3 | Upstream crude extraction |
- CBC (open-source MILP)
- GLPK
- Gurobi (commercial)
- IPOPT (NLP)
- SciPy (fallback)
python -m pytest tests/ -v- Gary, Handwerk, Kaiser — Petroleum Refining, 5th Ed.
- Riazi — Petroleum Fraction Characterization
- Li et al. (2016) — Nonlinear blending optimization
- GHG Protocol — Scope 3 Standard
See CONTRIBUTING.md for guidelines.
MIT License — see LICENSE.