π’οΈ Research-Grade Petroleum Refinery Optimization Platform
From Excel to Exascale: A complete toolkit for refinery blending, planning, and optimization.
Quick Start β’ Features β’ Installation β’ Documentation
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.