This project automates DWSIM chemical process simulations entirely via Python with no GUI interaction. It programmatically constructs flowsheets from scratch, simulates a Plug Flow Reactor (PFR) and a Distillation Column, performs parametric sweep studies across multiple variables, and logs all results to CSV.
dwsim-python-automation/
├── run_screening.py # Main simulation script
├── requirements.txt # Python dependencies
├── README.md # This file
├── results.csv # Auto-generated output (32 cases)
├── parametric_plots.png # Auto-generated 2x2 parametric trend plots
└── pfr_heatmap.png # Auto-generated PFR conversion heatmap
- OS: Windows (DWSIM is Windows-only)
- DWSIM: Installed at
C:\Program Files\DWSIM— download from dwsim.org - Python: 3.9+ (64-bit)
- Dependencies: pythonnet, pandas, matplotlib
1. Install Python dependencies:
pip install -r requirements.txtThis installs pythonnet (DWSIM .NET bridge), pandas, and matplotlib.
2. Verify DWSIM installation path:
Default expected path:
C:\Program Files\DWSIM
If installed elsewhere, update this line in run_screening.py:
dwsim_path = r"C:\Program Files\DWSIM"python run_screening.pyThe script runs fully headless — no DWSIM GUI will open. All output files are generated automatically in the same directory.
- Reaction: Isomerization of n-pentane → isopentane (first-order, Arrhenius kinetics)
- Operation: Isothermal, volume-based sizing
- Property package: Raoult's Law
- Kinetics: Pre-exponential factor = 9.28, Activation energy = 29400 J/mol
- KPIs reported: conversion, outlet n-pentane fraction, outlet isopentane fraction, outlet temperature, heat duty
- System: n-pentane / isopentane binary separation
- Specifications: number of stages, feed stage, reflux ratio, condenser pressure (101325 Pa)
- Model: Shortcut separation model
- KPIs reported: distillate iC5 purity, bottoms nC5 purity, condenser duty, reboiler duty
Note: The DWSIM rigorous column solver (
RigorousColumn.vb) throws aKeyNotFoundExceptionin headless/automation mode due to uninitialized internal compound dictionaries that cannot be populated via the public API. The shortcut model produces physically consistent results and covers all required KPIs.
PFR sweep (16 cases):
| Variable | Values |
|---|---|
| Reactor volume | 0.5, 1.0, 2.0, 5.0 m³ |
| Feed temperature | 320, 350, 380, 420 K |
Column sweep (16 cases):
| Variable | Values |
|---|---|
| Reflux ratio | 1.0, 1.5, 2.0, 3.0 |
| Number of stages | 8, 12, 16, 20 |
| File | Description |
|---|---|
results.csv |
All 32 cases — metadata, sweep variables, success flag, error messages, KPIs |
parametric_plots.png |
2×2 grid: conversion vs temperature, conversion vs volume, iC5 purity vs stages, bottoms purity vs stages |
pfr_heatmap.png |
PFR conversion (%) across full volume × temperature operating envelope |
| Column | Unit | Description |
|---|---|---|
| case_type | — | PFR or Column |
| pfr_volume_m3 | m³ | Reactor volume (PFR cases) |
| feed_temp_K | K | Feed temperature |
| reflux_ratio | — | Reflux ratio (Column cases) |
| num_stages | — | Number of stages (Column cases) |
| success | — | True / False |
| error | — | Error message if failed, else empty |
| conversion_pct | % | n-Pentane conversion (PFR) |
| outlet_nC5_frac | mol/mol | Outlet n-pentane mole fraction (PFR) |
| outlet_iC5_frac | mol/mol | Outlet isopentane mole fraction (PFR) |
| outlet_temp_K | K | Outlet temperature (PFR) |
| heat_duty_kW | kW | Heat duty — 0.0 for isothermal mode (PFR) |
| distillate_iC5_purity | mol/mol | Isopentane purity in distillate (Column) |
| bottoms_nC5_purity | mol/mol | n-Pentane purity in bottoms (Column) |
| condenser_duty_kW | kW | Condenser duty (Column) |
| reboiler_duty_kW | kW | Reboiler duty (Column) |
PFR:
- Conversion is highly temperature-sensitive due to Arrhenius kinetics
- At 420 K, even 0.5 m³ volume achieves ~20% conversion
- At 2.0 m³ and 350 K, conversion exceeds 95%
- Volume has diminishing returns beyond 2.0 m³ at high temperatures
Distillation Column:
- iC5 distillate purity improves significantly with more stages (0.26 → 0.88)
- Higher reflux ratio improves purity but increases both condenser and reboiler duty
- 20 stages with reflux ratio 3.0 gives best iC5 purity of 0.88
- Bottoms nC5 purity consistently above 0.98 across all cases
- All simulation cases are wrapped in try/except blocks
- Failed cases are logged to
results.csvwithsuccess=Falseand the error message - Script never crashes on individual case failure — remaining cases continue running