Chemical Engineering | Refinery Process Design | Heat Integration | Engineering Economics | Python | GitHub | Live Demo
A reproducible screening model of a representative 3,000 kg/h naphtha hydrodesulfurization (HDS) unit. The project combines component material balances, hydrogen demand, sulfur specification, process-to-process heat recovery, LMTD/exchanger-area screening, utility and CO2 estimates, reactor-volume screening, pressure-drop screening, sensitivity analysis, and bounded operating optimization.
Launch Interactive HDS Simulator
An interactive Streamlit interface for exploring the HDS material balance, heat integration, equipment screening, sensitivity analysis, and constrained operating optimization.
- Project Overview
- Key Features
- Process Flow
- Engineering Methodology
- Feed Basis
- Hydrodesulfurization Model
- Material Balances
- Heat Integration
- Heat Exchanger Sizing
- Reactor Sizing
- Hydraulic Screening
- Compressor Power
- Process Optimization
- Sensitivity Analysis
- Live Interactive Demo
- Results
- Baseline Results
- Optimized Results
- Project Structure
- Engineering Limitations
- Interview Talking Points
- References
- Future Improvements
- Author
- License
- Engineering takeaway
Naphtha hydrodesulfurization removes sulfur-containing compounds from naphtha before downstream processing. The engineering challenge is not only achieving the required sulfur specification, but doing so while balancing:
- hydrogen consumption,
- reactor operating temperature,
- heat recovery,
- furnace duty,
- exchanger area,
- reactor volume,
- hydraulic constraints,
- compressor power,
- and overall energy/environmental performance.
This project converts those trade-offs into a transparent computational workflow:
Feed Basis
↓
Component Material Balance
↓
HDS Stoichiometry
↓
H₂ Demand + H₂S Generation
↓
Sulfur Specification Check
↓
Reactor-Volume Screening
↓
Process-to-Process Heat Recovery
↓
LMTD + Heat-Exchanger Area
↓
Residual Furnace Duty
↓
Fuel / CO₂ Screening
↓
Hydraulic + Compressor Screening
↓
Temperature Sensitivity
↓
Constrained Operating Optimization
Find operating conditions that:
- satisfy the calculated product sulfur target of ≤10 ppm;
- respect the thermal feasibility constraints used by the model;
- reduce furnace duty through heat recovery;
- keep equipment-screening metrics visible;
- provide a reproducible basis for comparing operating scenarios.
- Component-level surrogate naphtha feed.
- Steady-state material balance.
- Explicit sulfur-species conversion.
- Stoichiometric hydrogen consumption.
- H₂S generation calculation.
- Product sulfur calculation in ppm.
- Sulfur-removal percentage.
- Reactor-effluent-to-feed heat recovery.
- Minimum temperature-approach constraint.
- LMTD calculation.
- Heat-exchanger area screening.
- Residual furnace duty.
- Fuel-consumption scenario estimate.
- Annual fuel-cost saving estimate.
- Annual CO₂-reduction scenario estimate.
- LHSV-based catalyst-bed volume.
- Gross reactor-volume estimate using void fraction.
- Darcy-Weisbach line pressure-drop screen.
- Reynolds number and friction-factor calculation.
- Ideal-gas isothermal compressor-power screen.
- Reactor-temperature sensitivity analysis.
- Bounded conversion sweep.
- Sulfur-specification constraint.
- Deterministic grid-search optimization.
- Baseline vs. optimized comparison.
- CSV result generation.
- Automated validation tests.
- Interactive Streamlit dashboard.
The simplified process representation used by the computational model is:
Naphtha Feed
│
├────────────── H₂
│
▼
Mixer / Feed Preparation
│
▼
Feed / Effluent Heat Exchanger
│
▼
Furnace
│
▼
HDS Reactor
│
▼
Cooling / Separation
│
▼
Desulfurized Naphtha
The hot reactor effluent is used as the heat source for preheating the cold feed. This creates the central energy-integration trade-off: recover more process heat to reduce furnace duty while respecting a minimum temperature approach.
The repository also generates a process-flow figure at:
figures/process_flow_diagram.png
The model uses a transparent surrogate naphtha rather than a proprietary or plant-specific assay.
| Parameter | Value |
|---|---|
| Naphtha feed | 3,000 kg/h |
| Feed temperature | 40 °C |
| Reactor pressure | 40 bar |
| Base reactor temperature | 350 °C |
| Fresh H₂ excess | 25% |
| Product sulfur target | ≤10 ppm |
| Minimum HX approach | 20 °C |
| Hot-side outlet target | 120 °C |
| LHSV screening basis | 3 h⁻¹ |
| HX U-value screening basis | 250 W/m²-K |
| Liquid density | 700 kg/m³ |
| Reactor void fraction | 0.40 |
| Annual operating hours | 8,000 h/y |
| Component | Mass fraction |
|---|---|
| n-Hexane | 0.350 |
| n-Heptane | 0.300 |
| n-Octane | 0.315 |
| Thiophene | 0.020 |
| Benzothiophene | 0.015 |
| Total | 1.000 |
The feed fractions are explicitly checked for closure before the material balance is performed.
Two representative sulfur species are modelled:
C₄H₄S + 4 H₂ → C₄H₁₀ + H₂S
C₈H₆S + 3 H₂ → C₈H₁₀ + H₂S
The model uses specified conversions rather than kinetic rate equations.
| Sulfur species | Base conversion |
|---|---|
| Thiophene | 99.99% |
| Benzothiophene | 99.98% |
For each sulfur species:
- feed mass is converted to kmol/h;
- reacted kmol/h is calculated from the specified conversion;
- stoichiometric H₂ demand is calculated;
- corresponding hydrocarbon product is generated;
- unreacted sulfur species remain in the product;
- H₂S production is calculated from sulfur-species conversion.
This approach is deliberately transparent and suitable for screening and sensitivity analysis, not detailed catalyst/reactor design.
The model calculates:
- feed component flowrates,
- reacted sulfur-species flowrates,
- unreacted sulfur-species flowrates,
- hydrocarbon product flowrates,
- stoichiometric H₂ demand,
- fresh H₂ requirement,
- H₂S generation,
- sulfur entering the reactor,
- sulfur remaining in the product,
- calculated product sulfur concentration,
- sulfur-removal percentage.
Fresh hydrogen is calculated as:
Fresh H₂ = Stoichiometric H₂ × 1.25
The remaining fresh H₂ is retained on the product-side accounting basis so that the overall mass balance closes.
The calculated product sulfur concentration is:
Product sulfur (ppm)
= Sulfur remaining in product / Total product mass × 10⁶
The process is considered specification-compliant when:
Product sulfur ≤ 10 ppm
The reactor effluent is treated as a hot process stream and the feed plus fresh hydrogen as the cold process stream.
The model applies constant heat capacities and a minimum temperature approach.
Qhot = Cp,hot × ΔT
Qcold = Cp,cold × ΔT
The recoverable heat is limited by the smaller of the two:
Qrecovered = min(Qhot, Qcold)
The model then calculates:
- hot-stream outlet temperature,
- cold-stream outlet temperature,
- LMTD,
- exchanger area,
- baseline furnace duty,
- integrated furnace duty,
- percentage heat-recovery saving.
The heat exchanger must satisfy the configured minimum approach of:
ΔTmin = 20 °C
The implementation rejects an infeasible reactor-temperature basis when the reactor temperature is too close to the configured hot-side outlet target.
The exchanger area is screened using:
A = Q / (U × LMTD)
where:
A= heat-transfer area, m²Q= recovered heat duty, WU= overall heat-transfer coefficient, W/m²-KLMTD= log-mean temperature difference, K
The configured screening value is:
U = 250 W/m²-K
For terminal temperature differences ΔT₁ and ΔT₂:
LMTD = (ΔT₁ - ΔT₂) / ln(ΔT₁ / ΔT₂)
The model also checks that the temperature-approach constraints remain valid.
Interpretation: The exchanger area is a preliminary screening estimate, not a mechanical design. Real exchanger design would require detailed fluid properties, fouling factors, pressure drops, geometry, allowable velocities, metallurgy, and vendor/design correlations.
The first-pass reactor screen uses liquid hourly space velocity:
LHSV = Liquid volumetric flow / Catalyst-bed volume
Therefore:
Catalyst-bed volume = Liquid volumetric flow / LHSV
The liquid feed volume is estimated from:
Liquid volumetric flow = Mass flow / Liquid density
Using:
- feed = 3,000 kg/h,
- liquid density = 700 kg/m³,
- LHSV = 3 h⁻¹,
the model calculates the catalyst-bed and gross reactor-volume screens.
The gross volume accounts for the configured reactor void fraction:
Gross reactor volume
= Catalyst-bed volume / (1 - void fraction)
with:
Void fraction = 0.40
A simplified line-pressure-drop calculation is included as a screening tool.
The model calculates:
- flow velocity,
- Reynolds number,
- friction factor,
- pressure drop.
The calculation uses a Darcy-Weisbach formulation:
ΔP = f × (L/D) × (ρv²/2)
For the friction factor, the implementation uses:
- laminar
64/Rebehaviour below the laminar threshold; - an explicit turbulent correlation using roughness and Reynolds number above the threshold.
| Parameter | Value |
|---|---|
| Diameter | 0.10 m |
| Length | 5.0 m |
| Density | 700 kg/m³ |
| Viscosity | 0.0004 Pa·s |
| Roughness | 4.5 × 10⁻⁵ m |
This is a line-screening calculation, not a packed-bed pressure-drop model. It should not be interpreted as an Ergun-based reactor pressure-drop calculation.
Hydrogen compressor power is screened using an ideal-gas isothermal-work relationship divided by compressor efficiency:
W = nRT ln(P₂/P₁) / η
The default screening basis uses:
| Parameter | Value |
|---|---|
| Suction pressure | 5 bar |
| Discharge pressure | 40 bar |
| Temperature | 313.15 K |
| Compressor efficiency | 72% |
The resulting value is a screening estimate, not a compressor datasheet/design calculation.
The optimization module performs a deterministic grid search over:
320–370 °C
in 5 °C increments.
99.90%
99.92%
99.94%
99.96%
99.98%
99.99%
99.995%
99.90%
99.92%
99.94%
99.96%
99.98%
99.99%
Only cases satisfying:
Calculated product sulfur ≤ 10 ppm
are retained.
Among feasible cases, the selected operating point minimizes:
- furnace duty;
- reactor temperature as a secondary tie-breaker.
This is a bounded deterministic grid search, not a nonlinear mathematical-programming solver.
The repository evaluates reactor-temperature sensitivity from:
320 °C → 370 °C
in 5 °C increments.
For each temperature, the model records:
- product sulfur,
- furnace duty,
- heat-exchanger area.
The generated results are stored in:
results/sensitivity_results.csv
and visualized through:
figures/furnace_duty_sensitivity.pngfigures/sulfur_sensitivity.png
At the base conversion values, calculated product sulfur remains approximately 1.474 ppm across the temperature sweep, because the current model specifies conversion independently of temperature.
Furnace duty increases across the temperature range, while exchanger area also increases. This is an important modelling insight: temperature sensitivity in the current model primarily affects thermal integration and equipment-screening metrics, not reaction conversion.
A more physically rigorous model would couple conversion to temperature through validated reaction kinetics.
The repository includes a Streamlit application in streamlit_app.py for interactive exploration of:
- reactor temperature and sulfur-species conversion inputs
- product sulfur and sulfur-removal KPIs
- fresh H2 demand and H2S generation
- heat recovery, LMTD and exchanger-area screening
- reactor volume, pressure-drop and compressor-power screens
- reactor-temperature sensitivity plots
- deterministic constrained optimization against the ≤10 ppm sulfur target
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux/macOS
source .venv/bin/activate
pip install -r requirements.txt
python -m pytest -q
streamlit run streamlit_app.pyThe browser application should open at the local Streamlit address shown in the terminal.
All headline values below are taken from the repository's generated CSV outputs rather than being manually invented for this README.
The current baseline case uses:
- 3,000 kg/h feed;
- 350 °C reactor temperature;
- 40 bar reactor pressure;
- 99.99% thiophene conversion;
- 99.98% benzothiophene conversion;
- 25% fresh-H₂ excess.
| Metric | Result |
|---|---|
| Feed | 3,000 kg/h |
| Reactor temperature | 350 °C |
| Reactor pressure | 40 bar |
| Fresh H₂ | 4.823 kmol/h |
| H₂ consumed | 3.858 kmol/h |
| H₂S produced | 1.048 kmol/h |
| Sulfur in | 33.614 kg/h |
| Sulfur out | 0.00444 kg/h |
| Calculated product sulfur | 1.474 ppm |
| Sulfur removal | 99.9868% |
| Heat recovered | 2,034.877 MJ/h |
| LMTD | 21.978 °C |
| HX area | 102.872 m² |
| Integrated furnace duty | 171.402 MJ/h |
| Heat-recovery saving | 92.231% |
| Catalyst-bed volume | 1.429 m³ |
| Gross reactor volume | 2.381 m³ |
| Screened line ΔP | 0.0102 kPa |
| H₂ compressor-power screen | 10.073 kW |
| Annual fuel saving | 325,580 kg/y |
| Annual fuel-cost saving | USD 179,069/y |
| Annual CO₂ reduction | 1,025,578 kg/y |
The baseline case comfortably satisfies the model's ≤10 ppm sulfur specification.
Source: results/baseline_results.csv.
The current deterministic grid search identifies the following feasible point:
| Metric | Optimized result |
|---|---|
| Reactor temperature | 320 °C |
| Thiophene conversion | 99.90% |
| Benzothiophene conversion | 99.94% |
| Calculated product sulfur | 9.740 ppm |
| Sulfur removal | 99.9128% |
| Furnace duty | 168.373 MJ/h |
| HX area | 93.079 m² |
| Heat-recovery saving | 91.551% |
Source: results/optimization_result.csv.
The optimization does not simply maximize conversion or temperature. It searches for a feasible operating point that meets the sulfur specification while minimizing furnace duty.
Compared with the baseline case, the selected point:
- reduces reactor temperature from 350 °C to 320 °C;
- reduces furnace duty from 171.402 to 168.373 MJ/h;
- reduces screened exchanger area from 102.872 to 93.079 m²;
- still meets the ≤10 ppm product-sulfur target.
This result should be interpreted strictly within the model assumptions. It does not prove that 320 °C is an industrially optimal HDS operating temperature because the current model does not contain temperature-dependent reaction kinetics, catalyst deactivation, rigorous phase behaviour, or detailed reactor hydraulics.
naphtha-hds-process-simulation-energy-optimization/
│
├── README.md
├── LICENSE
├── requirements.txt
├── streamlit_app.py
│
├── data/
│ └── feed_basis.csv
│
├── src/
│ ├── __init__.py
│ ├── config.py
│ ├── model.py
│ ├── equipment.py
│ ├── optimization.py
│ └── reporting.py
│
├── tests/
│ └── test_model.py
│
├── results/
│ ├── baseline_results.csv
│ ├── optimization_result.csv
│ └── sensitivity_results.csv
│
├── figures/
│ ├── process_flow_diagram.png
│ ├── heat_integration.png
│ ├── furnace_duty_sensitivity.png
│ └── sulfur_sensitivity.png
│
└── docs/
├── engineering_basis.md
├── final_report.txt
├── final_test_runs.txt
├── interview_guide.md
├── references.md
└── validation_log.md
This repository is intended for engineering learning, screening, comparison, and portfolio demonstration. It is not intended for plant operation or final equipment specification.
A real industrial HDS design would require, at minimum:
- rigorous phase-equilibrium calculations;
- realistic naphtha assay/pseudocomponents;
- temperature- and pressure-dependent physical properties;
- hydrogen/hydrocarbon phase behaviour;
- validated property methods.
- Langmuir-Hinshelwood or other validated kinetics;
- catalyst-specific activity;
- catalyst deactivation;
- reactor temperature profile;
- pressure drop through catalyst bed;
- catalyst loading and shape-factor considerations;
- validated reactor performance data.
- rigorous gas-liquid equilibrium;
- hydrogen recycle convergence;
- purge optimization;
- H₂S separation;
- amine treating and regeneration where applicable.
- detailed stream segmentation;
- multiple exchangers;
- pressure-drop constraints;
- fouling factors;
- exchanger configuration;
- metallurgy;
- mechanical design.
- detailed compressor design;
- pump sizing;
- control-valve sizing;
- relief-system design;
- equipment mechanical design;
- process-control strategy;
- HAZOP/LOPA and other safety studies.
- current equipment-cost basis;
- installation factors;
- utility pricing;
- maintenance and labour;
- lifecycle economics;
- emissions accounting boundaries;
- uncertainty analysis.
Accordingly, values such as annual fuel saving and annual CO₂ reduction should be interpreted as scenario calculations from the screening model, not plant-certified economic or environmental claims.
This project can support discussion around both chemical engineering and analytical decision making.
- Why is the H₂:N₂ feed ratio 3:1?
- Why is recycle required?
- Why is a purge required?
- Why does electrolysis dominate energy demand?
- Why does pressure influence ammonia synthesis?
- What is the role of NH₃ condensation?
- How would you validate the process in Aspen Plus?
- Which assumptions dominate LCOA?
- Why use deterministic grid search?
- How would you handle uncertainty?
- How would you introduce a pressure-dependent compressor model?
- How would you optimize for cost and carbon simultaneously?
- How would you model renewable intermittency?
- What would you change before calling this a bankable TEA?
"I intentionally separated the transparent screening layer from the rigorous validation layer. The Python model is useful for fast scenario analysis and optimization, while Aspen Plus should be used to validate thermodynamics, recycle convergence, phase behavior and unit-operation duties before treating the results as design-grade."
The repository maintains a separate reference landscape in:
docs/references.md
The reference landscape includes public examples covering:
- naphtha HDS and heat integration;
- Aspen Plus automation;
- process-simulation optimization;
- pinch-analysis workflows;
- chemical-engineering process design;
- equipment sizing/costing;
- CFD/process-engineering platforms.
The references are used for scope and workflow benchmarking, not as a source of copied project-specific calculations.
The next level of the project would move from a transparent screening model toward a more rigorous process-engineering simulator.
- Add temperature-dependent HDS kinetics.
- Model catalyst activity and deactivation.
- Couple conversion to reactor conditions.
- Add reactor-temperature-profile calculations.
- Add a thermodynamic property package.
- Introduce realistic pseudocomponents.
- Add VLE calculations.
- Improve hydrogen/hydrocarbon phase behaviour.
- Replace the LHSV-only screen with a kinetic reactor model.
- Add packed-bed pressure drop using the Ergun equation.
- Include catalyst density, voidage, and pellet properties.
- Evaluate reactor diameter and length.
- Move from a single process-to-process exchanger to a multi-stream HEN.
- Add pressure-drop constraints.
- Include fouling factors.
- Perform pinch analysis.
- Optimize exchanger network configuration.
- Add hydrogen recycle and purge.
- Model compressor stages.
- Include compressor efficiency maps.
- Optimize hydrogen utilization.
- Add equipment-cost correlations.
- Include utility costs.
- Add operating expenditure.
- Add capital expenditure.
- Calculate NPV, IRR, and payback period.
- Perform uncertainty/sensitivity analysis.
- Add scenario comparison.
- Add downloadable engineering reports.
- Add parameter provenance.
- Add automated regression testing.
- Add CI/CD validation through GitHub Actions.
Abhishek Kumar Gond
B.Tech in Chemical Engineering @ IIT Guwahati
- Email : mr.abhishekaaa@gmail.com
Released under the MIT License.
The central screening insight is straightforward:
For green ammonia, the cost and energy story is strongly driven by electricity-intensive hydrogen production.
The value of this project is not a single "optimal" number. It is the reproducible chain from engineering assumptions → process balances → energy → economics → emissions → optimization → validation.